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:
2026-10-30 00:10:38 +01:00
parent 4a0d4b0964
commit b515c16117
26 changed files with 98 additions and 70 deletions
@@ -59,6 +59,7 @@ vi.mock("../../features/player/PlayerModal", () => ({
import WatchedChannels from "./WatchedChannels";
import { qk } from "../../lib/queryKeys";
import { api, type Video, type WatchedChannel, type WatchedChannels as List } from "../../lib/api";
import { msg, type NotifText } from "../../lib/notifications";
afterEach(() => {
cleanup();
@@ -149,8 +150,10 @@ describe("WatchedChannels", () => {
fireEvent.click(await screen.findByRole("button", { name: "channels.watched.dismiss" }));
await waitFor(() => expect(h.notify).toHaveBeenCalled());
expect(dismiss).toHaveBeenCalledWith("UC1");
const toast = h.notify.mock.calls[0]![0] as { action: { label: string; onClick: () => void } };
expect(toast.action.label).toBe("common.undo");
const toast = h.notify.mock.calls[0]![0] as {
action: { label: NotifText; onClick: () => void };
};
expect(toast.action.label).toEqual(msg("common.undo"));
act(() => toast.action.onClick());
await waitFor(() => expect(restore).toHaveBeenCalledWith("UC1"));
});
@@ -74,7 +74,7 @@ export function useChannelActions({
level: "success",
message: msg("channels.notify.hidden", { name: nameOf(c) }),
action: {
label: t("common.undo"),
label: msg("common.undo"),
onClick: () => patch.mutate({ id: c.id, body: { hidden: false } }),
},
});
@@ -44,7 +44,7 @@ export function useWatchedChannelActions(onOpenWizard: () => void) {
notify({
level: "success",
message: msg("channels.watched.dismissed", { name: raw(nameOf(c)) }),
action: { label: t("common.undo"), onClick: () => restore.mutate(c) },
action: { label: msg("common.undo"), onClick: () => restore.mutate(c) },
});
},
});