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:
@@ -3,10 +3,12 @@ import { useLatest, useStableCallback } from "../../lib/useLatest";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { qk } from "../../lib/queryKeys";
|
||||
import { isResettable } from "../../lib/api/feed";
|
||||
import {
|
||||
addPlaylistItem,
|
||||
movePlaylistItem,
|
||||
removePlaylistItem,
|
||||
resetVideoState,
|
||||
writeVideoState,
|
||||
} from "../../features/video/videoWrites";
|
||||
import {
|
||||
@@ -25,7 +27,7 @@ import {
|
||||
verticalListSortingStrategy,
|
||||
} from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
import { Check, FolderInput, History, ListPlus, Play, X } from "lucide-react";
|
||||
import { Check, Eraser, FolderInput, History, ListPlus, Play, X } from "lucide-react";
|
||||
import { YouTubeIcon } from "../../lib/brandIcons";
|
||||
import {
|
||||
api,
|
||||
@@ -683,6 +685,16 @@ function PlaylistDetail() {
|
||||
return write;
|
||||
}
|
||||
|
||||
// Back to fresh (the video's state row and resume point both go), from the row's menu.
|
||||
function resetRow(id: string) {
|
||||
resetVideoState(qc, id)
|
||||
.then(() => {
|
||||
qc.invalidateQueries({ queryKey: qk.playlist() });
|
||||
qc.invalidateQueries({ queryKey: qk.feed(), refetchType: "none" });
|
||||
})
|
||||
.catch((e: unknown) => notifyActionError(e, msg("errors.writeFailed.videoReset")));
|
||||
}
|
||||
|
||||
// Stable identity: PlayerModal's keydown effect depends on it, so a fresh closure
|
||||
// every render re-subscribed those listeners and re-ran focusModal() under the open player.
|
||||
const closePlayer = () => setPlaying(null);
|
||||
@@ -732,6 +744,16 @@ function PlaylistDetail() {
|
||||
onSelect: () => openPlayer(ctxRow.id),
|
||||
},
|
||||
...comfortPin.item(pinVideo(ctxRow.id), raw(ctxRow.title ?? "")),
|
||||
...(isResettable(ctxRow)
|
||||
? [
|
||||
{
|
||||
id: "reset",
|
||||
label: t("card.resetState"),
|
||||
icon: <Eraser className="w-4 h-4" />,
|
||||
onSelect: () => resetRow(ctxRow.id),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...copy(ctxRow.title, ctxRow.watch_url).map((it, i) => ({
|
||||
...it,
|
||||
separatorBefore: i === 0,
|
||||
|
||||
Reference in New Issue
Block a user