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:
@@ -138,3 +138,35 @@ describe("useHistorySubview popstate", () => {
|
||||
expect(result.current.view).toBe("root");
|
||||
});
|
||||
});
|
||||
|
||||
// E28 review E1: a one-shot flag the view is OPENED with (the Plex player's `fromStart`, a card's
|
||||
// Restart) rode in history.state._sub, so a reload or a Forward onto that entry restarted from 0
|
||||
// again — and the player's checkpoint then overwrote the resume point. `entry` says what the
|
||||
// history entry keeps of a view; the view itself still opens with the flag.
|
||||
describe("useHistorySubview entry", () => {
|
||||
type V = { kind: string; once?: boolean };
|
||||
const withEntry: SubviewUrl<V> = {
|
||||
key: "v",
|
||||
encode: () => null,
|
||||
decode: () => null,
|
||||
entry: (v) => ({ kind: v.kind }),
|
||||
};
|
||||
|
||||
it("opens the view with the flag, but the history entry keeps it without", () => {
|
||||
const { result } = renderHook(() => useHistorySubview<V>({ kind: "root" }, withEntry));
|
||||
act(() => result.current.open({ kind: "player", once: true }));
|
||||
expect(result.current.view).toEqual({ kind: "player", once: true });
|
||||
expect(window.history.state._sub).toEqual({ kind: "player" });
|
||||
// A reload of that entry reads what the entry kept.
|
||||
const { result: reloaded } = renderHook(() =>
|
||||
useHistorySubview<V>({ kind: "root" }, withEntry),
|
||||
);
|
||||
expect(reloaded.current.view).toEqual({ kind: "player" });
|
||||
});
|
||||
|
||||
it("keeps it out of a replaced entry too", () => {
|
||||
const { result } = renderHook(() => useHistorySubview<V>({ kind: "root" }, withEntry));
|
||||
act(() => result.current.open({ kind: "player", once: true }, { replace: true }));
|
||||
expect(window.history.state._sub).toEqual({ kind: "player" });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user