fix: Refresh stale data when the app comes back from the background #30

Merged
namillis merged 1 commit from fix/refresh-on-resume into main 2026-11-06 04:51:21 +00:00
Owner

What was wrong

TVs keep LiveWire running when you close it, so reopening it resumes the same screen instead of starting fresh. Home, the Guide and Sports only checked whether their data was out of date when the screen first appeared, which never happens on a resume. The channels and guide stayed old until a force quit.

Home also skipped reloading now-playing on a stale refresh when the channel list hadn't changed, which is the usual case after a few hours away.

What changed

  • HomeScreen, GuideScreen, SportsScreen: the "screen shown" call moves from LaunchedEffect(Unit) to LifecycleStartEffect, so it also runs when the app returns to the foreground. The existing freshness windows still decide whether anything downloads (Home 10 min, Guide 30 min), so a quick return or coming back from the player costs nothing.
  • HomeViewModel.refreshIfStale: always reloads the guide (now-playing), and only rebuilds the lists when they changed.

Verified

  • testDebugUnitTest and lintDebug pass.
  • LiveWireTV_API34 emulator on the pool (tv1), with temporary logging (removed before commit), same process throughout:
    • Background, then reopen after ~1 minute: Home's check runs and downloads nothing.
    • Background, then reopen after 11 minutes: Home refreshes the channel lists and reloads now-playing.
## What was wrong TVs keep LiveWire running when you close it, so reopening it resumes the same screen instead of starting fresh. Home, the Guide and Sports only checked whether their data was out of date when the screen first appeared, which never happens on a resume. The channels and guide stayed old until a force quit. Home also skipped reloading now-playing on a stale refresh when the channel list hadn't changed, which is the usual case after a few hours away. ## What changed - `HomeScreen`, `GuideScreen`, `SportsScreen`: the "screen shown" call moves from `LaunchedEffect(Unit)` to `LifecycleStartEffect`, so it also runs when the app returns to the foreground. The existing freshness windows still decide whether anything downloads (Home 10 min, Guide 30 min), so a quick return or coming back from the player costs nothing. - `HomeViewModel.refreshIfStale`: always reloads the guide (now-playing), and only rebuilds the lists when they changed. ## Verified - `testDebugUnitTest` and `lintDebug` pass. - LiveWireTV_API34 emulator on the pool (tv1), with temporary logging (removed before commit), same process throughout: - Background, then reopen after ~1 minute: Home's check runs and downloads nothing. - Background, then reopen after 11 minutes: Home refreshes the channel lists and reloads now-playing.
fix: Refresh stale data when the app comes back from the background
All checks were successful
CI / test (pull_request) Successful in 5m45s
d35b49654d
TVs keep LiveWire running when it's closed, so reopening it resumes the
same screen. Home, the Guide and Sports only checked for stale data on
first composition, so nothing refreshed until a force quit.

Run those checks on ON_START (LifecycleStartEffect) instead. The existing
freshness windows still decide whether anything downloads (Home 10 min,
Guide 30 min). Home's stale refresh now always reloads now-playing, since
the channel list is often unchanged while the programmes are not.
namillis deleted branch fix/refresh-on-resume 2026-11-06 04:51:21 +00:00
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
namillis/LiveWireTV!30
No description provided.