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.
20 lines
744 B
TypeScript
20 lines
744 B
TypeScript
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 });
|
|
}
|