fix(player): a related video played is tracked, and its list is honest about its state
A related video played in place is the player's item now: its title and its own watched / playlist / download controls, its progress checkpointed and resumed, marked watched at its end — and its end does not step the queue. Back returns to the opened video, where it was left. The related list: - its marks announce through the shared notice (the Notification Center finds them), join the host's player session (the feed refetches on close), and stay per write, so an earlier answer no longer undoes a later mark still on its way; - every host's state write patches the cached related lists, which are never refetched; - kept for the session (gcTime), a retry asks for the page that failed, a list read so far with nothing unseen says so, a refusal a retry cannot answer offers none, and the followed mark names itself on hover. Turned off on the instance (a limit of 0), the tab, the drawer button and the live-search buttons are left out. Keys: the player's keys and its focus reclaim defer to a layer above it (the drawer); going wide moves the drawer's list into the panel's tab; `j` goes on from the slot of a row removed inside the top layer; the help sheet lists the list keys over a layer that holds a list.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import i18n from "../../i18n";
|
||||
import { notify, resolveVideo } from "../../lib/notifications";
|
||||
import type { Video, VideoStatus } from "../../lib/api";
|
||||
|
||||
/** What a notice names the video by; any of it may be unknown to the surface that marked it. */
|
||||
export type NoticeVideo = Pick<Video, "title" | "channel_id" | "channel_title">;
|
||||
|
||||
/** Say that a video's mark landed, once the server has it: "Hidden" / "Marked watched" with the
|
||||
* Undo (`undo` puts it back to new) and the meta the Notification Center keeps it under, so the
|
||||
* notice still finds the video after a reload. A mark back to new quietly resolves a hide or watch
|
||||
* notice still standing for it, so it does not linger with a dead action. A claim of success:
|
||||
* never called before the write is confirmed. One definition, because every list that marks a
|
||||
* video must announce it the same way (the feed's cards, a related list). */
|
||||
export function announceVideoState(
|
||||
id: string,
|
||||
status: VideoStatus,
|
||||
video: NoticeVideo | undefined,
|
||||
undo: () => void,
|
||||
): void {
|
||||
if (status === "new") {
|
||||
resolveVideo(id);
|
||||
return;
|
||||
}
|
||||
const hidden = status === "hidden";
|
||||
notify({
|
||||
message: video?.title
|
||||
? i18n.t(hidden ? "feed.hiddenNamed" : "feed.markedWatchedNamed", { title: video.title })
|
||||
: i18n.t(hidden ? "feed.hidden" : "feed.markedWatched"),
|
||||
action: { label: i18n.t(hidden ? "feed.undo" : "feed.unwatch"), onClick: undo },
|
||||
meta: {
|
||||
kind: hidden ? "video-hidden" : "video-watched",
|
||||
videoId: id,
|
||||
title: video?.title ?? i18n.t("feed.thisVideo"),
|
||||
channelId: video?.channel_id ?? "",
|
||||
channelName: video?.channel_title ?? "",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user