fix(notifications): a notice's button is said when shown, like its text
An action label was translated when the notice was raised, so after a language switch a live toast or center row read in one language with its button in the other. The access-requests nudge no longer re-issues on a switch for it. New tests: the button and a server refusal follow a switch.
This commit is contained in:
@@ -393,7 +393,7 @@ export default function NotificationsPanel() {
|
||||
: !n.dismissed
|
||||
? liveActions(n).map((action, i) => ({
|
||||
id: `action${i}`,
|
||||
label: action.label,
|
||||
label: sayNotif(action.label, t),
|
||||
onSelect: () => {
|
||||
action.onClick();
|
||||
dismissClient(n.id);
|
||||
@@ -570,7 +570,7 @@ export default function NotificationsPanel() {
|
||||
}
|
||||
|
||||
/** A client notice's live actions (they do not survive a reload): its action, then the lesser one. */
|
||||
function liveActions(n: ClientNotif): { label: string; onClick: () => void }[] {
|
||||
function liveActions(n: ClientNotif): NonNullable<ClientNotif["action"]>[] {
|
||||
return [n.action, n.secondaryAction].filter((a) => a !== undefined);
|
||||
}
|
||||
|
||||
@@ -920,7 +920,7 @@ function ClientActivityRow({
|
||||
<div className="mt-1 flex flex-wrap gap-x-4">
|
||||
{liveActions(n).map((action, i) => (
|
||||
<Button
|
||||
key={action.label}
|
||||
key={i}
|
||||
variant="link"
|
||||
className="text-sm"
|
||||
// The first is the row's own: Enter on the row runs it.
|
||||
@@ -930,7 +930,7 @@ function ClientActivityRow({
|
||||
dismissClient(n.id);
|
||||
}}
|
||||
>
|
||||
{action.label}
|
||||
{sayNotif(action.label, t)}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user