fix(player): short-video auto-watch + player cleanups
BUG (YB1): the auto-watch checkpoint marked a video watched once position crossed `duration - FINISH_MARGIN` (10s). For clips shorter than ~10s that threshold is negative, and for ~11-20s clips it's only a few seconds in, so the 5s checkpoint tick marked short videos watched almost immediately (clearing their resume position). Cap the margin at half the clip: Math.min(FINISH_MARGIN, dur/2). Cleanups (behavior-neutral): - Extract format.formatDate(iso, lang) — the day/month/year toLocaleDateString option object was duplicated verbatim in PlayerModal (fullDate) and VideoCard. (ChannelPage's "joined" is month/year only, so it's left as-is.) - The in-bar prev/next buttons now reuse goPrev/goNext instead of re-implementing the step + bounds inline (they already exist for the side arrows + keyboard). - Memoize savedPrefs so the ['me'] cache read + spread runs once, not on every render (it only seeds the initial autoMode/loopMode state). tsc green, knip clean, localdev boots healthy.
This commit is contained in:
parent
c0e941bc0c
commit
31c1284eb7
3 changed files with 26 additions and 26 deletions
|
|
@ -14,7 +14,7 @@ import AddToPlaylist from "./AddToPlaylist";
|
|||
import DownloadButton from "./DownloadButton";
|
||||
import clsx from "clsx";
|
||||
import type { Video } from "../lib/api";
|
||||
import { formatDuration, formatViews, relativeTime } from "../lib/format";
|
||||
import { formatDate, formatDuration, formatViews, relativeTime } from "../lib/format";
|
||||
|
||||
function Actions({
|
||||
video,
|
||||
|
|
@ -257,16 +257,7 @@ function VideoCard({
|
|||
</>
|
||||
)}
|
||||
{relativeTime(video.published_at)}
|
||||
{video.published_at && (
|
||||
<>
|
||||
{" · "}
|
||||
{new Date(video.published_at).toLocaleDateString(i18n.language, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
{video.published_at && <>{" · "}{formatDate(video.published_at, i18n.language)}</>}
|
||||
</>
|
||||
);
|
||||
// Show the full title in a native tooltip only when it's clamped (overflows its 2 lines).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue