fix(channels): every subscribe and unsubscribe refreshes the same reads

Each of the four sites kept its own invalidation list and each missed something (the channel menu's
unsubscribe left the feed showing the channel's videos; the channel page's left the counts stale).
lib/subscriptionCache invalidateSubscription is the one set; a contract test holds every call site
to it.
This commit is contained in:
2026-09-27 15:07:39 +02:00
parent eb339195c7
commit 3810af66da
5 changed files with 64 additions and 16 deletions
+19
View File
@@ -0,0 +1,19 @@
import type { QueryClient } from "@tanstack/react-query";
import { qk } from "./queryKeys";
/** Everything a subscribe or an unsubscribe changes: the channel itself, the manager's list and its
* counts, the feed and its facets (the channel's videos come or go), and discovery (a subscribed
* channel leaves it). ONE set for every site that makes the change (E28 review L8): each used to keep
* its own list, and each list missed something. */
export function invalidateSubscription(qc: QueryClient, channelId: string): void {
for (const queryKey of [
qk.channel(channelId),
qk.channels(),
qk.myStatus(),
qk.feed(),
qk.feedSummary(),
qk.discoveredChannels(),
])
void qc.invalidateQueries({ queryKey });
}