Give equal-weight actions equal-weight feedback (R11). S1 Plex error toasts: the watched-toggles (card / season mark-all / episode / info-panel / show mark-all) used to fail silently on 403/404/429; each now surfaces the server reason via a shared notifyActionError() + resyncs the optimistic flip. The playback auto-mark-watched stays intentionally silent (a mid-play toast is noise; the next sync corrects it). New generic lib/actionErrors.ts (Plex + saved views reuse it; notifyYouTubeActionError delegates its non-403 case to it). S2 download-done inbox notification: worker.py emits a best-effort type=download_done notice to the job owner on real completion (regular + edit jobs, not instant cache-hits), rendered/localized in the inbox with an Open-Downloads link. S3 optimistic rollbacks: SavedViewsWidget create/rename/toggle-default/remove/reorder and the inbox revert-state no longer swallow failures — they toast + refetch to resync (the reorder's optimistic order reverts to server truth). S4 access-request deny: deny_invite now emails the requester (send_access_denied), mirroring approve — no more silent limbo.
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { HttpError } from "./api";
|
|
import { notify } from "./notifications";
|
|
import { notifyActionError } from "./actionErrors";
|
|
import i18n from "../i18n";
|
|
|
|
// A YouTube-gated action (subscribe, sync, backfill, unsubscribe) that 403s means the user hasn't
|
|
// granted the write scope — surface a "Connect" affordance instead of a vague failure. Pass
|
|
// `onConnect` to offer the connect-wizard button (callers that have no wizard handle, e.g. the
|
|
// channel page, just get the message). `fallbackMessage` is the already-translated non-403 error.
|
|
export function notifyYouTubeActionError(
|
|
err: unknown,
|
|
fallbackMessage: string,
|
|
onConnect?: () => void,
|
|
): void {
|
|
const httpErr = err instanceof HttpError ? err : null;
|
|
if (httpErr?.status === 403) {
|
|
// A 403 on a YouTube write action means the write scope isn't granted — offer to connect.
|
|
notify({
|
|
level: "error",
|
|
message: i18n.t("channels.notify.needYouTube"),
|
|
action: onConnect
|
|
? { label: i18n.t("channels.notify.connect"), onClick: onConnect }
|
|
: undefined,
|
|
});
|
|
return;
|
|
}
|
|
// Any other error: prefer the server's own reason (e.g. "Not enough quota left today") over the
|
|
// caller's generic fallback — the useful detail was being discarded (U-3.2.8).
|
|
notifyActionError(err, fallbackMessage);
|
|
}
|