From 55dd1175207f2be8da18ef9fc3d457b0f74a1d6a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Apr 2026 06:40:53 -0500 Subject: [PATCH] Suppress photo-frame idle while Media overlay is open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Jellyfin runs in a cross-origin iframe so we can't observe the video element's play state directly — using overlay-open as the proxy. Any user activity still resets the timer, and Controls / Cameras / Settings overlays still fall to idle as before. --- src/hooks/useIdle.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/hooks/useIdle.ts b/src/hooks/useIdle.ts index cb5ea71..f63a59d 100644 --- a/src/hooks/useIdle.ts +++ b/src/hooks/useIdle.ts @@ -4,6 +4,9 @@ import { useUIStore } from '@/stores/uiStore'; /** * Tracks touch/mouse/keyboard activity. After `timeoutMs` of no activity, * flips the UI into idle mode (photo frame). Any activity exits idle. + * Idle is also suppressed while the Media overlay is open (Jellyfin runs + * in a cross-origin iframe, so we can't observe the video element's + * play state directly — the overlay being open is our proxy). */ export function useIdle(timeoutMs: number) { const isIdle = useUIStore((s) => s.isIdle); @@ -14,10 +17,21 @@ export function useIdle(timeoutMs: number) { let timer: ReturnType | null = null; - const reset = () => { + const schedule = () => { if (timer) clearTimeout(timer); + timer = setTimeout(() => { + // Re-check at fire time so "media overlay open" is always current + if (useUIStore.getState().mediaOverlayOpen) { + schedule(); + return; + } + setIdle(true); + }, timeoutMs); + }; + + const reset = () => { if (useUIStore.getState().isIdle) setIdle(false); - timer = setTimeout(() => setIdle(true), timeoutMs); + schedule(); }; const events: Array = [ @@ -29,7 +43,7 @@ export function useIdle(timeoutMs: number) { ]; for (const e of events) document.addEventListener(e, reset, { passive: true }); - reset(); + schedule(); return () => { if (timer) clearTimeout(timer);