This commit is contained in:
G1org1o 2025-11-17 23:52:30 +00:00 committed by GitHub
commit fafe25496d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 25 deletions

View File

@ -89,7 +89,7 @@ class TrackOptions extends HookConsumerWidget {
],
),
),
if (!isInQueue) ...[
if (!isInQueue)
ButtonTile(
style: ButtonVariance.menu,
onPressed: () async {
@ -103,20 +103,7 @@ 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,

View File

@ -228,24 +228,43 @@ class AudioPlayerNotifier extends Notifier<AudioPlayerState> {
final addableTracks = _blacklist
.filter(tracks)
.where(
.toList();
final remainingTracks = state.tracks.where(
(track) =>
allowDuplicates ||
!state.tracks.any((element) => _compareTracks(element, track)),
!addableTracks.any((element) => _compareTracks(element, track))
)
.toList();
state = state.copyWith(
tracks: [...addableTracks, ...state.tracks],
tracks: [...addableTracks, ...remainingTracks],
);
for (int i = 0; i < addableTracks.length; i++) {
final track = addableTracks.elementAt(i);
final (currentIndex, _) = remainingTracks
.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 || newIndex < 0) {
await audioPlayer.addTrackAt(
SpotubeMedia(track),
max(state.currentIndex, 0) + i + 1,
newIndex
);
} else {
await audioPlayer.moveTrack(currentIndex, newIndex);
}
}
await _updatePlayerState(