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:
@@ -1,5 +1,4 @@
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { Me } from "../lib/api";
|
||||
import type { Page } from "../lib/urlState";
|
||||
import { msg, notify, removeByMetaKind } from "../lib/notifications";
|
||||
@@ -8,13 +7,11 @@ import { focusAccessRequestsTab } from "../lib/adminUsersTab";
|
||||
type SetPage = (next: Page, then?: () => void) => void;
|
||||
|
||||
export function useAccessRequestsNudge(me: Me | null | undefined, setPage: SetPage): void {
|
||||
const { t } = useTranslation();
|
||||
// Nudge admins when access requests are waiting (in lieu of a server-push bell). Keyed on the
|
||||
// pending COUNT so it re-resolves the moment an approval/denial changes it — not only on a
|
||||
// fresh load (which is why the notice used to linger until F5 after an approval).
|
||||
// Honest deps, and `t` among them is a fix rather than a concession: the nudge is a persisted
|
||||
// toast whose text is translated at issue time, so a language switch must re-issue it. It did not
|
||||
// before — the notice stayed in the old language until the count changed.
|
||||
// No `t` among the deps: the nudge keeps what it says (its title, message and button), said in the
|
||||
// reader's language each time it is shown, so a language switch needs no re-issue.
|
||||
const role = me?.role;
|
||||
const pendingInvites = me?.pending_invites ?? 0;
|
||||
const pendingActivations = me?.pending_activations ?? 0;
|
||||
@@ -36,7 +33,7 @@ export function useAccessRequestsNudge(me: Me | null | undefined, setPage: SetPa
|
||||
// gets a click via the action.
|
||||
meta: { kind: "access-requests" },
|
||||
action: {
|
||||
label: t("common.accessRequestsReview"),
|
||||
label: msg("common.accessRequestsReview"),
|
||||
onClick: () => {
|
||||
focusAccessRequestsTab();
|
||||
// Clicked inside whatever overlay hosts the toast; setPage closes it before pushing.
|
||||
@@ -45,5 +42,5 @@ export function useAccessRequestsNudge(me: Me | null | undefined, setPage: SetPa
|
||||
},
|
||||
});
|
||||
}
|
||||
}, [role, pendingInvites, pendingActivations, t, setPage]);
|
||||
}, [role, pendingInvites, pendingActivations, setPage]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user