feat: auto-refresh of recently played history#1123
Conversation
Greptile SummaryThis PR implements automatic refresh of the recently-played history list in the Radio LUZ feature. It wires up a Confidence Score: 4/5Safe to merge with awareness of one minor redundant network request on startup; no correctness or data-loss issues The previously reported race condition is correctly addressed with the isClosed guard. The Riverpod patterns used (ref.listen + invalidateSelf inside an async provider, setRefresh) are idiomatic and sound. The only remaining issue is that _lastTrackTitle initialising to null causes one spurious track-changed event ~15 s after the page loads, triggering an unnecessary extra history fetch per session. This is a P2 concern — it wastes one network call at startup but does not break any user-facing behaviour or produce incorrect data. lib/features/radio_luz/service/radio_audio_handler.dart — the _lastTrackTitle initialisation Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as RadioLuzView
participant HR as historyEntryRepository
participant TCP as radioTrackChangedProvider
participant RA as RadioAudioHandlerBridge
participant API as Radio LUZ API
UI->>HR: watch (page open, t=0)
HR->>API: getRecentlyPlayed()
API-->>HR: history list
HR-->>UI: IList<HistoryEntry>
Note over HR: setRefresh(60s) timer started
Note over HR: ref.listen(radioTrackChangedProvider) set up
loop Every 15 s
RA->>API: getNowPlaying()
API-->>RA: nowPlaying
alt track title changed
RA->>TCP: trackChanged.add(title)
TCP-->>HR: AsyncValue<String> (hasValue)
HR->>HR: invalidateSelf()
HR->>API: getRecentlyPlayed()
API-->>HR: updated history
HR-->>UI: IList<HistoryEntry> (refreshed)
end
end
Note over HR: Fallback: 60 s timer fires invalidateSelf()
UI->>HR: pull-to-refresh → ref.refresh(future)
HR->>API: getRecentlyPlayed()
API-->>HR: history list
HR-->>UI: IList<HistoryEntry>
Reviews (2): Last reviewed commit: "fix: greptile changes" | Re-trigger Greptile |
I've made it to auto-refresh whenever new song appears on currently playing + fallback every 60 seconds. Why? Becuase as for my findings the recently played list does not have the newly played song as fast as the currently played endpoint so it wouldnt update until next new song is played. I think this is a good middle-ground
This change also adresses what greptile told was wrong in the other branch