feat(player): a bookmark reopens every player as it was, once

The Plex player names the playlist it plays through (v=player:<id>:playlist:<pid>), so a bookmark
rebuilds the queue from the playlist's own order while the item is still in it.

Found in the browser and fixed:
- after a reload the shell's player opened a second one over Home and the feed: it read the catalog
  row the page had fetched (a disabled query still reads the shared cache); it now waits for ready.
- every reload under an open overlay left a dead history step: the first overlay to open takes over
  the entry the document was loaded on.
- the feed's address was implicit, the same as the start-page landing, so a reloaded or bookmarked
  feed opened as Home: the feed now names itself (page=feed) like every page.
- a linked file or video that is gone was said, but stayed in the address and was said again on
  every reload: its keys are taken off.

The overlay address is written in one place (the entry is named once it is current), and the player
keys only the codec reads are no longer exported.
This commit is contained in:
2026-10-27 07:33:55 +01:00
parent fa893c73a3
commit 3d26ca0efa
23 changed files with 343 additions and 53 deletions
@@ -181,6 +181,7 @@ afterEach(() => {
mocks.titleArgs = [];
mocks.wideLoading = false;
mocks.wideFailed = false;
mocks.searched = [];
mocks.notify.mockClear();
resetQueueWatch();
});
@@ -776,6 +777,24 @@ describe("Files · a file the address names", () => {
expect(await screen.findByText("playing 1")).toBeTruthy();
});
it("past the cap, waits for the server's sorted list to look for it — and finds it there", async () => {
window.history.replaceState(null, "", "/?page=files&fsort=name:asc&fview=9999");
mocks.files = Array.from({ length: FILES_LIST_CAP }, (_, i) => file(i + 1));
mocks.folders = [YT];
mocks.wideLoading = true;
mount();
await new Promise((r) => setTimeout(r, 20));
// The newest files alone do not hold it: not "gone" while the server's answer is on its way.
expect(mocks.notify).not.toHaveBeenCalled();
expect(screen.queryByRole("dialog")).toBeNull();
cleanup();
mocks.wideLoading = false;
mocks.searched = [doc(9999)];
mount();
const dialog = await screen.findByRole("dialog");
expect(dialog.querySelector("iframe")!.getAttribute("src")).toBe(api.previewUrl(9999));
}, 30_000); // a full page of FILES_LIST_CAP rows, drawn twice (see "a library past the list's cap")
it("says so when the list no longer holds it", async () => {
window.history.replaceState(null, "", "/?page=files&fview=99");
mocks.files = [doc(2)];
@@ -787,6 +806,8 @@ describe("Files · a file the address names", () => {
),
);
expect(screen.queryByRole("dialog")).toBeNull();
// Said once: the address no longer names it, so a reload or a copied link does not say it again.
expect(here().has("fview")).toBe(false);
});
});