From 970e725d39a64a2999d1991f22ef61ea4806967a Mon Sep 17 00:00:00 2001 From: npeter83 Date: Sat, 11 Jul 2026 18:11:23 +0200 Subject: [PATCH] =?UTF-8?q?fix(channels):=20ChannelPage=20subscribe=20?= =?UTF-8?q?=E2=80=94=20surface=20403=20+=20fix=20stale=20caches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- frontend/src/components/ChannelPage.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/components/ChannelPage.tsx b/frontend/src/components/ChannelPage.tsx index 2c81407..08e259b 100644 --- a/frontend/src/components/ChannelPage.tsx +++ b/frontend/src/components/ChannelPage.tsx @@ -6,6 +6,7 @@ import Avatar from "./Avatar"; import Feed from "./Feed"; import { useConfirm } from "./ConfirmProvider"; import { notify } from "../lib/notifications"; +import { notifyYouTubeActionError } from "../lib/youtubeErrors"; import { api, type FeedFilters, type Me } from "../lib/api"; import { channelYouTubeUrl, formatViews } from "../lib/format"; @@ -89,8 +90,14 @@ export default function ChannelPage({ qc.invalidateQueries({ queryKey: ["channel", channelId] }); qc.invalidateQueries({ queryKey: ["feed"] }); 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 ?? "" }) }); }, + // 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({ mutationFn: () => api.unsubscribeChannel(channelId),