fix: liked state not showing until track row disappears/reappears

likedTrackIds loads async after views appear, so isLiked was always
false on initial render. Add onChange(of: likedTrackIds) to all track
row types and the player bar to re-sync when the set is populated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ultradesu
2026-06-09 10:49:05 +01:00
parent bdab606360
commit 37a6ccaf0c
5 changed files with 7 additions and 0 deletions
+1
View File
@@ -203,6 +203,7 @@ private struct ArtistTrackRow: View {
.contentShape(Rectangle())
.onTapGesture { onPlay() }
.onAppear { isLiked = authManager.likedTrackIds.contains(track.id) }
.onChange(of: authManager.likedTrackIds) { _, ids in isLiked = ids.contains(track.id) }
.popover(isPresented: $showInfo, arrowEdge: .trailing) {
TrackInfoView(track: track)
}
+3
View File
@@ -64,6 +64,9 @@ struct ContentView: View {
.onChange(of: player.currentTrack?.id) { _, newId in
isCurrentTrackLiked = newId.map { authManager.likedTrackIds.contains($0) } ?? false
}
.onChange(of: authManager.likedTrackIds) { _, ids in
isCurrentTrackLiked = player.currentTrack.map { ids.contains($0.id) } ?? false
}
.onChange(of: deviceManager.remoteState?.updatedAtMs) { _, _ in
remoteSeekOverride = nil
}
+1
View File
@@ -172,6 +172,7 @@ private struct PlaylistTrackRow: View {
.contentShape(Rectangle())
.onTapGesture { onPlay() }
.onAppear { isLiked = authManager.likedTrackIds.contains(track.id) }
.onChange(of: authManager.likedTrackIds) { _, ids in isLiked = ids.contains(track.id) }
.popover(isPresented: $showInfo, arrowEdge: .trailing) {
TrackInfoView(track: track)
}
+1
View File
@@ -170,6 +170,7 @@ private struct ReleaseTrackRow: View {
.contentShape(Rectangle())
.onTapGesture { onPlay() }
.onAppear { isLiked = authManager.likedTrackIds.contains(track.id) }
.onChange(of: authManager.likedTrackIds) { _, ids in isLiked = ids.contains(track.id) }
.popover(isPresented: $showInfo, arrowEdge: .trailing) {
TrackInfoView(track: track)
}
+1
View File
@@ -137,6 +137,7 @@ private struct TrackRowSearch: View {
.contentShape(Rectangle())
.onTapGesture { onPlay() }
.onAppear { isLiked = authManager.likedTrackIds.contains(track.id) }
.onChange(of: authManager.likedTrackIds) { _, ids in isLiked = ids.contains(track.id) }
.popover(isPresented: $showInfo, arrowEdge: .trailing) {
TrackInfoView(track: track)
}