From 37a6ccaf0cb9a92bfbe585d9899430d53276a663 Mon Sep 17 00:00:00 2001 From: Ultradesu Date: Tue, 9 Jun 2026 10:49:05 +0100 Subject: [PATCH] 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 --- furumi_macos/ArtistScreen.swift | 1 + furumi_macos/ContentView.swift | 3 +++ furumi_macos/PlaylistScreen.swift | 1 + furumi_macos/ReleaseScreen.swift | 1 + furumi_macos/SearchResultsView.swift | 1 + 5 files changed, 7 insertions(+) diff --git a/furumi_macos/ArtistScreen.swift b/furumi_macos/ArtistScreen.swift index ecd40fb..c9ce47a 100644 --- a/furumi_macos/ArtistScreen.swift +++ b/furumi_macos/ArtistScreen.swift @@ -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) } diff --git a/furumi_macos/ContentView.swift b/furumi_macos/ContentView.swift index 640d437..c816c3a 100644 --- a/furumi_macos/ContentView.swift +++ b/furumi_macos/ContentView.swift @@ -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 } diff --git a/furumi_macos/PlaylistScreen.swift b/furumi_macos/PlaylistScreen.swift index bc3e0dc..1d2fa5c 100644 --- a/furumi_macos/PlaylistScreen.swift +++ b/furumi_macos/PlaylistScreen.swift @@ -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) } diff --git a/furumi_macos/ReleaseScreen.swift b/furumi_macos/ReleaseScreen.swift index 31a770b..ac80d3e 100644 --- a/furumi_macos/ReleaseScreen.swift +++ b/furumi_macos/ReleaseScreen.swift @@ -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) } diff --git a/furumi_macos/SearchResultsView.swift b/furumi_macos/SearchResultsView.swift index 36817f9..ed6f5c3 100644 --- a/furumi_macos/SearchResultsView.swift +++ b/furumi_macos/SearchResultsView.swift @@ -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) }