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:
@@ -25,7 +25,7 @@ import Tooltip from "../../components/ui/Tooltip";
|
||||
import VideoCard from "../video/VideoCard";
|
||||
import { VideoMenu } from "../video/VideoMenu";
|
||||
import { announceVideoState } from "../video/stateNotice";
|
||||
import { writeVideoState, writeWatchLater } from "../video/videoWrites";
|
||||
import { resetVideoState, writeVideoState, writeWatchLater } from "../video/videoWrites";
|
||||
import { msg } from "../../lib/notifications";
|
||||
|
||||
/** Which list YouTube fills in — on the video's topic or with what trends in Hungary — is a mood,
|
||||
@@ -106,6 +106,21 @@ export function RelatedVideos({
|
||||
});
|
||||
};
|
||||
|
||||
const onResetState = (id: string) => {
|
||||
const seq = begin(id, { status: "new", position_seconds: 0 });
|
||||
const write = resetVideoState(qc, id);
|
||||
onWrite?.(write);
|
||||
write
|
||||
.then(() => {
|
||||
settle(seq);
|
||||
void qc.invalidateQueries({ queryKey: qk.feed(), refetchType: "none" });
|
||||
})
|
||||
.catch((e: unknown) => {
|
||||
notifyActionError(e, msg("errors.writeFailed.videoReset"));
|
||||
settle(seq);
|
||||
});
|
||||
};
|
||||
|
||||
const onToggleSave = (id: string, saved: boolean) => {
|
||||
const seq = begin(id, { saved });
|
||||
const write = writeWatchLater(qc, id, saved);
|
||||
@@ -231,7 +246,7 @@ export function RelatedVideos({
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<VideoMenu menu={menu} handlers={{ onState, onToggleSave, onOpen: open }} />
|
||||
<VideoMenu menu={menu} handlers={{ onState, onToggleSave, onResetState, onOpen: open }} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user