Compare commits

..

1 Commits

Author SHA1 Message Date
G1org1o
fafe25496d
Merge d291ae4bce into 826c8e4dd6 2025-11-17 23:52:30 +00:00
2 changed files with 15 additions and 4 deletions

View File

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

View File

@ -230,10 +230,21 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
.filter(tracks)
.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++) {
final track = addableTracks.elementAt(i);
final (currentTrackIndex, _) = state.tracks
final (currentIndex, _) = remainingTracks
.indexed
.cast<(int, SpotubeTrackObject?)>()
.firstWhere(
@ -246,13 +257,13 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
final newIndex = max(state.currentIndex, 0) + i + 1;
if (allowDuplicates || currentTrackIndex < 0) {
if (allowDuplicates || newIndex < 0) {
await audioPlayer.addTrackAt(
SpotubeMedia(track),
newIndex
);
} else {
await audioPlayer.moveTrack(currentTrackIndex, newIndex);
await audioPlayer.moveTrack(currentIndex, newIndex);
}
}