feat(video): Reset view on every YouTube video menu

The row that sets a video back to fresh (its state row and resume point both
go) was only on the feed's cards. It is now on Home's shelves, a Playlists
row's menu and the player's related list too, and is named "Reset view" /
"Megtekintés visszaállítása".
This commit is contained in:
2026-11-01 01:20:20 +01:00
parent 15a3603513
commit e06c0688d9
11 changed files with 115 additions and 12 deletions
@@ -46,12 +46,14 @@ vi.mock("react-i18next", async (importOriginal) => {
const discover = vi.fn();
const discoverPick = vi.fn();
const videoRow = vi.fn();
const clearState = vi.fn((_id: string) => Promise.resolve());
vi.mock("../../lib/api", () => ({
api: {
discover: (...a: unknown[]) => discover(...a),
videoRow: (...a: unknown[]) => videoRow(...a),
discoverPick: (...a: unknown[]) => discoverPick(...a),
setState: () => Promise.resolve(),
clearState: (id: string) => clearState(id),
watchLaterAdd: () => Promise.resolve(),
watchLaterRemove: () => Promise.resolve(),
downloadIndex: () => Promise.resolve({}), // the cards' download buttons read it
@@ -803,6 +805,25 @@ describe("Home", () => {
expect(setPage).toHaveBeenCalledWith("plex");
});
it("a started video's menu resets its view, and Home asks again", async () => {
discover.mockResolvedValue({
budget: "any",
hero: null,
continue_watching: [ytCard("v1", "Half seen")],
comfort: [],
});
mount();
fireEvent.click((await screen.findAllByRole("button", { name: "card.menu.more" }))[0]!);
const reset = screen
.getAllByRole("menuitem", { hidden: true })
.find((b) => b.textContent === "card.resetState");
expect(reset).toBeTruthy();
const asked = discover.mock.calls.length;
fireEvent.click(reset!);
await waitFor(() => expect(clearState).toHaveBeenCalledWith("v1"));
await waitFor(() => expect(discover.mock.calls.length).toBeGreaterThan(asked));
});
// C5: what a tile's Play would continue, its menu can start over — the one way to on touch.
it("a started film's menu starts it over: the player opens from the start", async () => {
const movie = {
+14 -2
View File
@@ -52,7 +52,11 @@ import SegmentedToggle from "../../components/ui/SegmentedToggle";
import { LoadingState, StateMessage } from "../../components/ui/QueryState";
import VideoCard, { VideoHoverActions } from "../../features/video/VideoCard";
import { useVideoActions } from "../../features/video/useVideoActions";
import { writeVideoState, writeWatchLater } from "../../features/video/videoWrites";
import {
resetVideoState,
writeVideoState,
writeWatchLater,
} from "../../features/video/videoWrites";
import { usePlexCardActions } from "../../features/plexCards/usePlexCardActions";
import { PlexHoverBar, PlexPosterCard } from "../../features/plexCards/plexCards";
import { usePlaylistsActions } from "../playlists";
@@ -156,7 +160,15 @@ function useHomeCardMenu({
const pin = useComfortPin(menu.open);
// A video tile's own action list, the same one the feed's menu shows; the rail keeps its
// Play row (it resolves `next`) and its shelf rows around it.
const videoActions = useVideoActions({ onState, onToggleSave }, menu.open);
const qc = useQueryClient();
// Back to fresh: what the rails answer changes with it (a reset video leaves Continue watching),
// so Home asks again, as its marks do.
const onResetState = (id: string) => {
void resetVideoState(qc, id)
.then(() => qc.invalidateQueries({ queryKey: qk.discover() }))
.catch((e: unknown) => notifyActionError(e, msg("errors.writeFailed.videoReset")));
};
const videoActions = useVideoActions({ onState, onToggleSave, onResetState }, menu.open);
// A Plex tile's, likewise (its "Media info" row goes where the tile's `onInfo` does).
const plexActions = usePlexCardActions(
{