fix(channels): ChannelPage subscribe — surface 403 + fix stale caches
BUG (FB3): the channel page's Subscribe mutation had no onError, so a read-only user (no YouTube write scope) clicking Subscribe got a silent 403 — nothing happened, no toast. Wire notifyYouTubeActionError (no wizard handle here, so the message without the Connect button). Block is a local-only action and can't 403 for scope, so it's left as-is. BUG (FB4): subscribe.onSuccess invalidated channel/feed/channels but omitted my-status and discovered-channels (which ChannelDiscovery invalidates for the same action), so after subscribing from a channel page the Discovery list and the manager stats stayed stale. Added both. tsc green, localdev boots healthy.
This commit is contained in:
parent
ee601363c2
commit
970e725d39
1 changed files with 7 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import Avatar from "./Avatar";
|
||||||
import Feed from "./Feed";
|
import Feed from "./Feed";
|
||||||
import { useConfirm } from "./ConfirmProvider";
|
import { useConfirm } from "./ConfirmProvider";
|
||||||
import { notify } from "../lib/notifications";
|
import { notify } from "../lib/notifications";
|
||||||
|
import { notifyYouTubeActionError } from "../lib/youtubeErrors";
|
||||||
import { api, type FeedFilters, type Me } from "../lib/api";
|
import { api, type FeedFilters, type Me } from "../lib/api";
|
||||||
import { channelYouTubeUrl, formatViews } from "../lib/format";
|
import { channelYouTubeUrl, formatViews } from "../lib/format";
|
||||||
|
|
||||||
|
|
@ -89,8 +90,14 @@ export default function ChannelPage({
|
||||||
qc.invalidateQueries({ queryKey: ["channel", channelId] });
|
qc.invalidateQueries({ queryKey: ["channel", channelId] });
|
||||||
qc.invalidateQueries({ queryKey: ["feed"] });
|
qc.invalidateQueries({ queryKey: ["feed"] });
|
||||||
qc.invalidateQueries({ queryKey: ["channels"] });
|
qc.invalidateQueries({ queryKey: ["channels"] });
|
||||||
|
// Match ChannelDiscovery: the channel leaves discovery and the manager's stats move.
|
||||||
|
qc.invalidateQueries({ queryKey: ["my-status"] });
|
||||||
|
qc.invalidateQueries({ queryKey: ["discovered-channels"] });
|
||||||
notify({ level: "info", message: t("channel.subscribed", { name: ch?.title ?? "" }) });
|
notify({ level: "info", message: t("channel.subscribed", { name: ch?.title ?? "" }) });
|
||||||
},
|
},
|
||||||
|
// A 403 (missing write scope) otherwise fails silently on the channel page (no wizard handle
|
||||||
|
// here, so no Connect button — but the user at least sees why it didn't work).
|
||||||
|
onError: (err) => notifyYouTubeActionError(err, t("channels.discovery.subscribeFailed")),
|
||||||
});
|
});
|
||||||
const unsubscribe = useMutation({
|
const unsubscribe = useMutation({
|
||||||
mutationFn: () => api.unsubscribeChannel(channelId),
|
mutationFn: () => api.unsubscribeChannel(channelId),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue