fix(notifications): name the entity in action toasts

Eight confirmations stated a bare fact without saying what they acted on. Pass
the entity through the mutation variables and interpolate it: channel
unsubscribe/reset name the channel, whitelist/demo-whitelist adds name the
email, tag delete names the tag, and playlist revert/push name the playlist.
EN/HU/DE.
This commit is contained in:
npeter83 2026-06-26 00:32:17 +02:00
parent 557f2cef9c
commit 6c4c33f956
16 changed files with 45 additions and 43 deletions

View file

@ -242,10 +242,10 @@ function AdminInvites() {
});
const add = useMutation({
mutationFn: (email: string) => api.addInvite(email),
onSuccess: () => {
onSuccess: (_d, email) => {
setNewEmail("");
refresh();
notify({ level: "success", message: t("settings.invites.addedToWhitelist") });
notify({ level: "success", message: t("settings.invites.addedToWhitelist", { email }) });
},
onError: () => notify({ level: "error", message: t("settings.invites.addFailed") }),
});
@ -324,10 +324,10 @@ function AdminDemo() {
const add = useMutation({
mutationFn: (email: string) => api.addDemoWhitelist(email),
onSuccess: () => {
onSuccess: (_d, email) => {
setNewEmail("");
qc.invalidateQueries({ queryKey: ["demo-whitelist"] });
notify({ level: "success", message: t("settings.demo.added") });
notify({ level: "success", message: t("settings.demo.added", { email }) });
},
onError: () => notify({ level: "error", message: t("settings.demo.addFailed") }),
});

View file

@ -157,20 +157,20 @@ export default function Channels({
onError: (e) => notifyActionError(e, "channels.notify.syncFailed"),
});
const unsubscribe = useMutation({
mutationFn: (id: string) => api.unsubscribeChannel(id),
onSuccess: () => {
mutationFn: (v: { id: string; name: string }) => api.unsubscribeChannel(v.id),
onSuccess: (_d, v) => {
qc.invalidateQueries({ queryKey: ["channels"] });
qc.invalidateQueries({ queryKey: ["my-status"] });
notify({ level: "success", message: t("channels.notify.unsubscribed") });
notify({ level: "success", message: t("channels.notify.unsubscribed", { name: v.name }) });
},
onError: (e) => notifyActionError(e, "channels.notify.unsubscribeFailed"),
});
const resetBackfill = useMutation({
mutationFn: (id: string) => api.resetChannelBackfill(id),
onSuccess: () => {
mutationFn: (v: { id: string; name: string }) => api.resetChannelBackfill(v.id),
onSuccess: (_d, v) => {
qc.invalidateQueries({ queryKey: ["channels"] });
qc.invalidateQueries({ queryKey: ["my-status"] });
notify({ level: "success", message: t("channels.notify.resetDone") });
notify({ level: "success", message: t("channels.notify.resetDone", { name: v.name }) });
},
onError: (e) => notifyActionError(e, "channels.notify.resetFailed"),
});
@ -210,7 +210,7 @@ export default function Channels({
confirmLabel: t("channels.row.unsubscribeOnYoutube"),
danger: true,
});
if (ok) unsubscribe.mutate(c.id);
if (ok) unsubscribe.mutate({ id: c.id, name: c.title ?? c.id });
};
const onReset = async (c: ManagedChannel) => {
const ok = await confirm({
@ -218,7 +218,7 @@ export default function Channels({
message: t("channels.confirmReset", { name: c.title ?? c.id }),
confirmLabel: t("channels.row.backfillThis"),
});
if (ok) resetBackfill.mutate(c.id);
if (ok) resetBackfill.mutate({ id: c.id, name: c.title ?? c.id });
};
const columns: Column<ManagedChannel>[] = [

View file

@ -353,11 +353,12 @@ export default function Playlists({ canWrite }: { canWrite: boolean }) {
danger: true,
});
if (!ok) return;
const plName = detail.kind === "watch_later" ? t("playlists.watchLater") : detail.name;
setReverting(true);
try {
await api.revertPlaylist(selectedId);
refreshAll();
notify({ level: "success", message: t("playlists.revertDone") });
notify({ level: "success", message: t("playlists.revertDone", { name: plName }) });
} catch {
notify({ level: "warning", message: t("playlists.revertFailed") });
} finally {
@ -367,11 +368,12 @@ export default function Playlists({ canWrite }: { canWrite: boolean }) {
async function pushToYoutube() {
if (selectedId == null || !detail || pushing) return;
const plName = detail.kind === "watch_later" ? t("playlists.watchLater") : detail.name;
setPushing(true);
try {
const plan = await api.playlistPushPlan(selectedId);
if (plan.action === "update" && !plan.to_insert && !plan.to_delete && !plan.to_reorder) {
notify({ level: "info", message: t("playlists.pushUpToDate") });
notify({ level: "info", message: t("playlists.pushUpToDate", { name: plName }) });
return;
}
if (!plan.affordable) {
@ -410,7 +412,7 @@ export default function Playlists({ canWrite }: { canWrite: boolean }) {
if (r.failures.length) {
notify({ level: "warning", message: t("playlists.pushPartial", { count: r.failures.length }) });
} else {
notify({ level: "success", message: t("playlists.pushDone") });
notify({ level: "success", message: t("playlists.pushDone", { name: plName }) });
}
} catch {
notify({ level: "warning", message: t("playlists.pushFailed") });

View file

@ -137,10 +137,10 @@ export default function TagManager({
onSuccess: invalidate,
});
const del = useMutation({
mutationFn: (id: number) => api.deleteTag(id),
onSuccess: () => {
mutationFn: (v: { id: number; name: string }) => api.deleteTag(v.id),
onSuccess: (_d, v) => {
invalidate();
notify({ level: "success", message: t("tagManager.deleted") });
notify({ level: "success", message: t("tagManager.deleted", { name: v.name }) });
},
});
@ -179,7 +179,7 @@ export default function TagManager({
});
if (!ok) return;
}
del.mutate(tag.id);
del.mutate({ id: tag.id, name: tag.name });
}}
/>
))}