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.
30 lines
1.3 KiB
TypeScript
30 lines
1.3 KiB
TypeScript
import { HttpError } from "./api";
|
|
import { markReported } from "./api/core";
|
|
import { msg, notify, type NotifText } from "./notifications";
|
|
import { notifyActionError } from "./actionErrors";
|
|
|
|
// 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 what a non-403 error says.
|
|
export function notifyYouTubeActionError(
|
|
err: unknown,
|
|
fallbackMessage: NotifText,
|
|
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: msg("channels.notify.needYouTube"),
|
|
action: onConnect ? { label: msg("channels.notify.connect"), onClick: onConnect } : undefined,
|
|
});
|
|
markReported(err);
|
|
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);
|
|
}
|