mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-06 07:29:42 +00:00
Compare commits
No commits in common. "686638a9184f9af212e954296213a43c1340036b" and "d291ae4bce7433913d5e0f88d916ba0dca6cfb63" have entirely different histories.
686638a918
...
d291ae4bce
@ -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,
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user