updates and bug fixes
This commit is contained in:
parent
8aacce5aa8
commit
351d47b3ff
9 changed files with 419 additions and 64 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue