From 397aedf2d8f314e0339a3e0c81d446a3e61acf7c Mon Sep 17 00:00:00 2001 From: ScreenTinker Date: Tue, 9 Jun 2026 08:30:58 -0500 Subject: [PATCH] fix(player-web): don't optimistic-render fullscreen when layout is unknown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to the layout cache. On a cold start with a cached playlist but no cached layout yet (first run after shipping, or cleared cache), the player still rendered fullscreen and flashed before the payload arrived. Now gate the optimistic cached render on the layout being KNOWN (cache key present — null=fullscreen vs object= zoned, both fine); if unknown, wait ~1s for the payload to drive the first render. Eliminates the fullscreen flash on the very first pass too. --- server/player/index.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/player/index.html b/server/player/index.html index 56f57f7..1b42d86 100644 --- a/server/player/index.html +++ b/server/player/index.html @@ -517,13 +517,18 @@ } if (config.serverUrl && config.deviceId && config.paired) { - // Restore cached playlist immediately so content plays even if offline + // Restore cached playlist immediately so content plays even if offline — + // but ONLY if we also know the layout, else we'd guess fullscreen and flash + // before the payload arrives. Key presence (not value) is the test: an absent + // key means "layout unknown" (e.g. first run after this shipped, or cleared + // cache), while a stored `null` is a real fullscreen device. Both caches are + // written on every payload, so after the first connection this always renders + // immediately; only a genuinely-unknown layout waits (~1s) for the payload. const cachedPlaylist = loadPlaylistCache(); - if (cachedPlaylist.length > 0) { + const layoutKnown = localStorage.getItem(LAYOUT_CACHE_KEY) !== null; + if (cachedPlaylist.length > 0 && layoutKnown) { console.log('Restored cached playlist:', cachedPlaylist.length, 'items'); playlist = cachedPlaylist; - // Restore the cached layout too, so the first render is already zoned - // (otherwise the cold start shows fullscreen until the payload arrives). layout = loadLayoutCache(); currentIndex = 0; isPlaying = true;