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:
2026-10-25 00:32:28 +02:00
parent d53729a63d
commit b5045165c0
30 changed files with 1024 additions and 207 deletions
+15 -3
View File
@@ -1,5 +1,5 @@
import { useEffect, useEffectEvent, useState, type RefObject } from "react";
import { dispatch, useKeyScope } from "./keymap";
import { dispatch, setListInTopLayerProbe, useKeyScope } from "./keymap";
import { anyBlockingLayer, topBlockingLayerRoot } from "./layerStack";
import { scrollParent } from "./listPaging";
import { focusIsUnclaimed } from "./useFocusKeeper";
@@ -101,6 +101,12 @@ function current(): { list: NavList; index: number; item: HTMLElement } | null {
* move between the items, so a surface that also binds them (the player's seek) leaves them alone. */
export const focusInNavList = (): boolean => current() !== null;
// The help sheet lists the list keys over a layer only when this says there is a list to walk in it.
setListInTopLayerProbe(() => {
const layer = topBlockingLayerRoot();
return !!layer && [...lists.keys()].some((el) => layer.contains(el));
});
/** The mounted items that belong to `el` itself (not to a list nested inside it), in index order. */
function ownItems(el: HTMLElement): HTMLElement[] {
return [...el.querySelectorAll<HTMLElement>(`[${INDEX}]`)]
@@ -335,10 +341,16 @@ function onKey(e: KeyboardEvent): void {
if (move(dx, dy)) ev.preventDefault();
};
// The list keys act on the page, so an open layer silences them — unless the focus is in a list
// INSIDE the topmost layer: that list is what the user is in (the player's related videos).
// INSIDE the topmost layer: that list is what the user is in (the player's related videos). Or was,
// a moment ago: a row marked from its menu leaves the list and the focus falls to <body>, and `j`
// goes on from its slot (`slotOfRemoved`) as it does on the page.
const layer = topBlockingLayerRoot();
const cur = current();
const inTopLayer = !!layer && !!cur && layer.contains(cur.item);
const inTopLayer =
!!layer &&
(cur
? layer.contains(cur.item)
: focusIsUnclaimed(document.activeElement) && !!last && layer.contains(last.list.el));
dispatch(
e,
"list",