fix(player): a related video played is tracked, and its list is honest about its state
A related video played in place is the player's item now: its title and its own watched / playlist / download controls, its progress checkpointed and resumed, marked watched at its end — and its end does not step the queue. Back returns to the opened video, where it was left. The related list: - its marks announce through the shared notice (the Notification Center finds them), join the host's player session (the feed refetches on close), and stay per write, so an earlier answer no longer undoes a later mark still on its way; - every host's state write patches the cached related lists, which are never refetched; - kept for the session (gcTime), a retry asks for the page that failed, a list read so far with nothing unseen says so, a refusal a retry cannot answer offers none, and the followed mark names itself on hover. Turned off on the instance (a limit of 0), the tab, the drawer button and the live-search buttons are left out. Keys: the player's keys and its focus reclaim defer to a layer above it (the drawer); going wide moves the drawer's list into the panel's tab; `j` goes on from the slot of a row removed inside the top layer; the help sheet lists the list keys over a layer that holds a list.
This commit is contained in:
@@ -84,3 +84,21 @@ export function patchCachedProgress(qc: QueryClient, positions: Map<string, numb
|
||||
qc.setQueriesData<Cached>({ queryKey: qk.ytSearch() }, patch);
|
||||
qc.setQueriesData<Cached>({ queryKey: qk.related() }, patch);
|
||||
}
|
||||
|
||||
/** Write one video's change (its status, its Watch-later mark) into every cached related list —
|
||||
* both regions', every opened video's. Those lists are never refetched (another scrape and a slot
|
||||
* of the day's cap), and they leave out what the user has seen: a video marked anywhere else — a
|
||||
* feed card, a playlist, the player itself — still showed in one opened again later. So every
|
||||
* state write calls it once the server has the change. */
|
||||
export function patchRelated(qc: QueryClient, id: string, change: Partial<Video>): void {
|
||||
qc.setQueriesData<Cached>({ queryKey: qk.related() }, (old) => {
|
||||
if (!old?.pages) return old;
|
||||
let changed = false;
|
||||
const pages = old.pages.map((page) => {
|
||||
if (!isItemList(page) || !page.items.some((v) => v.id === id)) return page;
|
||||
changed = true;
|
||||
return { ...page, items: page.items.map((v) => (v.id === id ? { ...v, ...change } : v)) };
|
||||
});
|
||||
return changed ? { ...old, pages } : old;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user