Skip to content

Commit

Permalink
Fix deselect all
Browse files Browse the repository at this point in the history
  • Loading branch information
nt4f04uNd committed Jul 13, 2024
1 parent 7b787a0 commit 17e1df9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
16 changes: 13 additions & 3 deletions lib/logic/models/selection_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,23 @@ class SelectionEntry<T extends Content> {
origin: selectionRouteOf(context) && song.origin is DuplicatingSongOriginMixin ? song.origin : null,
) as SelectionEntry<T>;
case ContentType.album:
return SelectionEntry<Album>(
index: index,
data: content as Album,
origin: null,
) as SelectionEntry<T>;
case ContentType.playlist:
return SelectionEntry<Playlist>(
index: index,
data: content as Playlist,
origin: null,
) as SelectionEntry<T>;
case ContentType.artist:
return SelectionEntry<T>(
return SelectionEntry<Artist>(
index: index,
data: content,
data: content as Artist,
origin: null,
);
) as SelectionEntry<T>;
}
}

Expand Down
23 changes: 13 additions & 10 deletions lib/logic/player/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -988,16 +988,19 @@ class ContentUtils {
final List<SelectionEntry<Playlist>> playlists = [];
final List<SelectionEntry<Artist>> artists = [];
for (final entry in data) {
if (entry is SelectionEntry<Song>) {
songs.add(entry);
} else if (entry is SelectionEntry<Album>) {
albums.add(entry);
} else if (entry is SelectionEntry<Playlist>) {
playlists.add(entry);
} else if (entry is SelectionEntry<Artist>) {
artists.add(entry);
} else {
throw UnimplementedError();
switch (entry.data.type) {
case ContentType.song:
songs.add(entry as SelectionEntry<Song>);
break;
case ContentType.album:
albums.add(entry as SelectionEntry<Album>);
break;
case ContentType.playlist:
playlists.add(entry as SelectionEntry<Playlist>);
break;
case ContentType.artist:
artists.add(entry as SelectionEntry<Artist>);
break;
}
}
if (sort) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,7 @@ class SelectAllSelectionAction<T extends Content> extends StatelessWidget {
final first = all.first;
assert(all.every((el) => el.runtimeType == first.runtimeType));

final selectedOfThisType = controller.data.where((el) => el.runtimeType == entryFactory(first, 0).runtimeType);
final selectedOfThisType = controller.data.where((el) => el.data.type == entryFactory(first, 0).data.type);
bool allSelected = true;
for (int i = 0; i < all.length; i++) {
if (!selectedOfThisType.contains(entryFactory(all[i], i))) {
Expand Down

0 comments on commit 17e1df9

Please sign in to comment.