mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-05 23:19:42 +00:00
Merge 686638a918 into 826c8e4dd6
This commit is contained in:
commit
ac3714f344
@ -89,7 +89,7 @@ class TrackOptions extends HookConsumerWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!isInQueue) ...[
|
||||
if (!isInQueue)
|
||||
ButtonTile(
|
||||
style: ButtonVariance.menu,
|
||||
onPressed: () async {
|
||||
@ -102,21 +102,8 @@ class TrackOptions extends HookConsumerWidget {
|
||||
},
|
||||
leading: const Icon(SpotubeIcons.queueAdd),
|
||||
title: Text(context.l10n.add_to_queue),
|
||||
),
|
||||
ButtonTile(
|
||||
style: ButtonVariance.menu,
|
||||
onPressed: () async {
|
||||
await trackOptionActions.action(
|
||||
rootNavigatorKey.currentContext!,
|
||||
TrackOptionValue.playNext,
|
||||
playlistId,
|
||||
);
|
||||
onTapItem?.call();
|
||||
},
|
||||
leading: const Icon(SpotubeIcons.lightning),
|
||||
title: Text(context.l10n.play_next),
|
||||
),
|
||||
] else
|
||||
)
|
||||
else
|
||||
ButtonTile(
|
||||
style: ButtonVariance.menu,
|
||||
onPressed: () async {
|
||||
@ -131,6 +118,19 @@ class TrackOptions extends HookConsumerWidget {
|
||||
leading: const Icon(SpotubeIcons.queueRemove),
|
||||
title: Text(context.l10n.remove_from_queue),
|
||||
),
|
||||
ButtonTile(
|
||||
style: ButtonVariance.menu,
|
||||
onPressed: () async {
|
||||
await trackOptionActions.action(
|
||||
rootNavigatorKey.currentContext!,
|
||||
TrackOptionValue.playNext,
|
||||
playlistId,
|
||||
);
|
||||
onTapItem?.call();
|
||||
},
|
||||
leading: const Icon(SpotubeIcons.lightning),
|
||||
title: Text(context.l10n.play_next),
|
||||
),
|
||||
if (isAuthenticated && !isLocalTrack)
|
||||
ButtonTile(
|
||||
style: ButtonVariance.menu,
|
||||
|
||||
@ -228,24 +228,32 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
|
||||
|
||||
final addableTracks = _blacklist
|
||||
.filter(tracks)
|
||||
.where(
|
||||
(track) =>
|
||||
allowDuplicates ||
|
||||
!state.tracks.any((element) => _compareTracks(element, track)),
|
||||
)
|
||||
.toList();
|
||||
|
||||
state = state.copyWith(
|
||||
tracks: [...addableTracks, ...state.tracks],
|
||||
);
|
||||
|
||||
for (int i = 0; i < addableTracks.length; i++) {
|
||||
final track = addableTracks.elementAt(i);
|
||||
|
||||
final (currentTrackIndex, _) = state.tracks
|
||||
.indexed
|
||||
.cast<(int, SpotubeTrackObject?)>()
|
||||
.firstWhere(
|
||||
(record) {
|
||||
final (idx, element) = record;
|
||||
return _compareTracks(element!, track);
|
||||
},
|
||||
orElse: () => (-1, null)
|
||||
);
|
||||
|
||||
final newIndex = max(state.currentIndex, 0) + i + 1;
|
||||
|
||||
if (allowDuplicates || currentTrackIndex < 0) {
|
||||
await audioPlayer.addTrackAt(
|
||||
SpotubeMedia(track),
|
||||
max(state.currentIndex, 0) + i + 1,
|
||||
newIndex
|
||||
);
|
||||
} else {
|
||||
await audioPlayer.moveTrack(currentTrackIndex, newIndex);
|
||||
}
|
||||
}
|
||||
|
||||
await _updatePlayerState(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user