updates and bug fixes

This commit is contained in:
Forrest 2026-07-30 11:39:33 -04:00
parent 8aacce5aa8
commit 351d47b3ff
9 changed files with 419 additions and 64 deletions

View file

@ -64,6 +64,27 @@ class FavoritesController extends StateNotifier<FavoritesState> {
void clear() => state = const FavoritesState();
/// Fold a song's own server-provided star / rating into local state when it
/// isn't tracked yet. Songs surfaced outside the Favorites tab (browse, home,
/// queue) carry their `starred` flag directly, so this lets the heart light
/// up for previously-favorited tracks even when `getStarred2` hydration is
/// incomplete. Only fills gaps — it never re-adds a star the user cleared
/// this session, since callers invoke it on track change (not on toggle) and
/// it only adds when the song itself reports starred.
void seedSong(Song song) {
Set<String>? songIds;
Map<String, int>? ratings;
if (song.starred && !state.songIds.contains(song.id)) {
songIds = {...state.songIds, song.id};
}
if (song.userRating != null && !state.ratings.containsKey(song.id)) {
ratings = {...state.ratings, song.id: song.userRating!};
}
if (songIds != null || ratings != null) {
state = state.copyWith(songIds: songIds, ratings: ratings);
}
}
Future<void> toggleSong(Song song) async {
final client = _clientGetter();
if (client == null) return;

View file

@ -474,9 +474,10 @@ final playbackProvider =
return client.coverArtUri(s.coverArt!, size: 512);
}
return PlaybackController(
final controller = PlaybackController(
streamUriFor: streamUriFor,
coverArtUriFor: coverArtUriFor,
serverKeyGetter: () => ref.read(serverKeyProvider),
onArt: (artUri) async {
// Skip extraction entirely when the user has pinned a static accent.
if (ref.read(settingsProvider).useStaticAccent) return;
@ -489,4 +490,11 @@ final playbackProvider =
ref.read(subsonicClientProvider)?.scrobble(song.id).ignore();
},
);
// Restore the persisted queue on connect / server switch, and catch the
// already-connected case at creation (the listener only fires on changes).
ref.listen<String?>(serverKeyProvider, (_, _) {
controller.restoreForServer();
});
controller.restoreForServer();
return controller;
});