feat/widget-flicker-fix #10

Merged
CodyWan-Kenobi merged 0 commits from refs/pull/10/head into main 2026-06-21 05:29:01 +00:00
CodyWan-Kenobi commented 2026-06-21 04:21:46 +00:00 (Migrated from codeberg.org)

Summary

Stabilizes the Navidrome and Jellyfin "Now Playing" widgets in their idle state and tightens Navidrome's freshness window.

  • The "Nothing playing right now" empty state no longer flickers every 10 s.
  • After stopping a Navidrome track, the widget clears within ~2 min instead of ~10 min.
  • Transient backend errors no longer flash an error banner — the last-good render is preserved.

What was wrong

  • Stale-closure flicker (both widgets): isInitialLoad was useState(true) but captured by the setInterval closure, so every poll ran
    setLoading(true)→false, briefly unmounting the empty state. Fixed with a useRef so the flag reads live.
  • Navidrome error churn: unconditional setError(null)/setError(msg) each poll swapped render branches on any transient hiccup. Now errors only surface
    on first load; transient failures keep the last-good render.
  • Identity churn: setNowPlaying([]) etc. fired every poll even when unchanged. Now guarded with functional updaters that return prev when identical.
  • Navidrome staleness: Subsonic's getNowPlaying returns ~10 min of recent plays, not just current. Server now filters entries with minutesAgo > 2.

Files

  • client/src/components/widgets/NavidromeWidget.tsx
  • client/src/components/widgets/JellyfinWidget.tsx
  • server/src/services/navidrome.service.ts

No dependency, env, or API changes. tsc --noEmit clean.

Notes

  • The 2-min Navidrome threshold is a fixed constant; happy to make it configurable if preferred.
  • The same useState + setInterval stale-closure pattern likely exists in other widgets (Weather, Linkding, FreshRSS) — can follow up separately.
Summary Stabilizes the Navidrome and Jellyfin "Now Playing" widgets in their idle state and tightens Navidrome's freshness window. - The "Nothing playing right now" empty state no longer flickers every 10 s. - After stopping a Navidrome track, the widget clears within ~2 min instead of ~10 min. - Transient backend errors no longer flash an error banner — the last-good render is preserved. What was wrong - Stale-closure flicker (both widgets): isInitialLoad was useState(true) but captured by the setInterval closure, so every poll ran setLoading(true)→false, briefly unmounting the empty state. Fixed with a useRef so the flag reads live. - Navidrome error churn: unconditional setError(null)/setError(msg) each poll swapped render branches on any transient hiccup. Now errors only surface on first load; transient failures keep the last-good render. - Identity churn: setNowPlaying([]) etc. fired every poll even when unchanged. Now guarded with functional updaters that return prev when identical. - Navidrome staleness: Subsonic's getNowPlaying returns ~10 min of recent plays, not just current. Server now filters entries with minutesAgo > 2. Files - client/src/components/widgets/NavidromeWidget.tsx - client/src/components/widgets/JellyfinWidget.tsx - server/src/services/navidrome.service.ts No dependency, env, or API changes. tsc --noEmit clean. Notes - The 2-min Navidrome threshold is a fixed constant; happy to make it configurable if preferred. - The same useState + setInterval stale-closure pattern likely exists in other widgets (Weather, Linkding, FreshRSS) — can follow up separately.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
thelinuxcast/Homepage!10
No description provided.