Skip to content

Commit

Permalink
fix: selecting duplicated tracks
Browse files Browse the repository at this point in the history
in playlists, history, queues, etc
  • Loading branch information
MSOB7YY committed Apr 21, 2024
1 parent 492813e commit 56b1471
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions lib/controller/selected_tracks_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ class SelectedTracksController {
void selectOrUnselect(Selectable track, QueueSource queueSource, String? playlistName) {
playlistName ??= '';
final rawTrack = track.track;
final didRemove = _allTracksHashCodes.remove(rawTrack) ?? false;
if (didRemove) {
_tracksOrTwdList.remove(track);
selectedPlaylistsNames.remove(track);
if (isTrackSelected(track)) {
_allTracksHashCodes.remove(rawTrack);
final indexInList = _tracksOrTwdList.indexWhere((element) => element.track == rawTrack);
if (indexInList != -1) _tracksOrTwdList.removeAt(indexInList);
selectedPlaylistsNames.remove(rawTrack);
} else {
_tracksOrTwdList.add(track);
_allTracksHashCodes[rawTrack] = true;
selectedPlaylistsNames[track.track] = playlistName;
_tracksOrTwdList.add(track);
selectedPlaylistsNames[rawTrack] = playlistName;
}

bottomPadding.value = _tracksOrTwdList.isEmpty ? 0.0 : 102.0;
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/widgets/selected_tracks_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class SelectedTracksPreviewContainer extends StatelessWidget {
key: ValueKey(stc.selectedTracks[i]),
onDismissed: (direction) => stc.removeTrack(i),
child: TrackTile(
key: Key('$i${stc.selectedTracks[i].track.path}'),
key: Key('$i${stc.selectedTracks[i]}'),
index: i,
trackOrTwd: stc.selectedTracks[i],
displayRightDragHandler: true,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 2.0.6+240407151
version: 2.0.6-beta+240421222

environment:
sdk: ">=3.1.4 <4.0.0"
Expand Down

0 comments on commit 56b1471

Please sign in to comment.