Merge pull request #47 from screentinker/fix/player-coldstart-layout

fix(player-web): no fullscreen flash on true cold start (unknown layout)
This commit is contained in:
screentinker 2026-06-09 08:31:03 -05:00 committed by GitHub
commit 7af9f7a057
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;