Compare commits

..

3 Commits

Author SHA1 Message Date
G1org1o
ac3714f344
Merge 686638a918 into 826c8e4dd6 2025-11-19 12:07:38 +00:00
G1org1owo
686638a918 Fix state getting reassigned incorrectly and check on wrong index 2025-11-19 13:08:31 +01:00
G1org1owo
a37fc4546b Fix extra comma 2025-11-18 11:54:41 +01:00
2 changed files with 4 additions and 15 deletions

View File

@ -102,7 +102,7 @@ class TrackOptions extends HookConsumerWidget {
}, },
leading: const Icon(SpotubeIcons.queueAdd), leading: const Icon(SpotubeIcons.queueAdd),
title: Text(context.l10n.add_to_queue), title: Text(context.l10n.add_to_queue),
), )
else else
ButtonTile( ButtonTile(
style: ButtonVariance.menu, style: ButtonVariance.menu,

View File

@ -230,21 +230,10 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
.filter(tracks) .filter(tracks)
.toList(); .toList();
final remainingTracks = state.tracks.where(
(track) =>
allowDuplicates ||
!addableTracks.any((element) => _compareTracks(element, track))
)
.toList();
state = state.copyWith(
tracks: [...addableTracks, ...remainingTracks],
);
for (int i = 0; i < addableTracks.length; i++) { for (int i = 0; i < addableTracks.length; i++) {
final track = addableTracks.elementAt(i); final track = addableTracks.elementAt(i);
final (currentIndex, _) = remainingTracks final (currentTrackIndex, _) = state.tracks
.indexed .indexed
.cast<(int, SpotubeTrackObject?)>() .cast<(int, SpotubeTrackObject?)>()
.firstWhere( .firstWhere(
@ -257,13 +246,13 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
final newIndex = max(state.currentIndex, 0) + i + 1; final newIndex = max(state.currentIndex, 0) + i + 1;
if (allowDuplicates || newIndex < 0) { if (allowDuplicates || currentTrackIndex < 0) {
await audioPlayer.addTrackAt( await audioPlayer.addTrackAt(
SpotubeMedia(track), SpotubeMedia(track),
newIndex newIndex
); );
} else { } else {
await audioPlayer.moveTrack(currentIndex, newIndex); await audioPlayer.moveTrack(currentTrackIndex, newIndex);
} }
} }