fix(plex): a Restart does not replay on a reload or a Forward onto the player

fromStart rode in history.state._sub, so reloading the player entry restarted
the item from 0 again and the progress checkpoint overwrote its resume point.
A sub-view config can now say what the history entry keeps of a view.
This commit is contained in:
2026-09-27 14:03:48 +02:00
parent de62035889
commit 383c85231a
4 changed files with 57 additions and 2 deletions
@@ -76,3 +76,18 @@ describe("PLEX_SUB_URL decode guards", () => {
expect(U.decode("")).toBeNull();
});
});
describe("PLEX_SUB_URL entry", () => {
// E28 review E1: the Restart click must not replay on a reload / Forward onto the player entry.
it("keeps the player without its one-shot fromStart, and every other view whole", () => {
const entry = U.entry!;
expect(entry({ kind: "player", id: "7", queue: ["7", "8"], fromStart: true })).toEqual({
kind: "player",
id: "7",
queue: ["7", "8"],
fromStart: undefined,
});
const info = { kind: "info", id: "7" } as const;
expect(entry(info)).toBe(info);
});
});
+4
View File
@@ -49,6 +49,10 @@ export const PLEX_SUB_URL: SubviewUrl<Sub> = {
return null; // discover (root) + the ephemeral player are not URL-mirrored
}
},
// `fromStart` is the Restart CLICK, not a property of the entry: kept in history.state it restarted
// the item from 0 again on every reload or Forward onto the player, and the progress checkpoint
// then overwrote the resume point it had skipped (E28 review E1).
entry: (v) => (v.kind === "player" && v.fromStart ? { ...v, fromStart: undefined } : v),
decode: (raw) => {
const i = raw.indexOf(":");
const kind = i === -1 ? raw : raw.slice(0, i);