From edbd83f8e831791e2fd9cd444f539966d903a6fb Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 26 May 2026 22:38:19 +0200 Subject: [PATCH] refactor: share time formatter --- static/player/timeline.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/static/player/timeline.ts b/static/player/timeline.ts index 5347948..79ac2c9 100644 --- a/static/player/timeline.ts +++ b/static/player/timeline.ts @@ -1,13 +1,6 @@ import type { TimelineBounds } from './types'; import { state } from './state'; - -// mm:ss formatter -const formatTime = (seconds: number): string => { - if (!Number.isFinite(seconds) || seconds < 0) return '00:00'; - const mins = Math.floor(seconds / 60); - const secs = Math.floor(seconds % 60); - return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`; -}; +import { formatTime } from './controls'; // cached to avoid recalc on every timeupdate let cachedBounds: TimelineBounds = { start: 0, end: 0, duration: 0 }; @@ -65,7 +58,6 @@ export const getBounds = (): TimelineBounds => { const duration = getDuration(); const seekableEnd = getSeekableEnd(); if ( - !cachedBounds || cachedBounds.duration <= 0 || duration !== cachedDuration || seekableEnd !== cachedSeekableEnd