mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
fix(generate_playlist): create playlist not adding tracks nor navigating to playlist page
This commit is contained in:
parent
c709de6bf1
commit
bd4cd22e4e
@ -101,11 +101,17 @@ class PlaylistCreateDialog extends HookConsumerWidget {
|
||||
} else {
|
||||
await playlistNotifier.create(payload, onError);
|
||||
}
|
||||
|
||||
if (trackIds.isNotEmpty) {
|
||||
await playlistNotifier.addTracks(trackIds, onError);
|
||||
}
|
||||
} finally {
|
||||
isSubmitting.value = false;
|
||||
if (context.mounted &&
|
||||
!ref.read(playlistProvider(playlistId ?? "")).hasError) {
|
||||
context.router.maybePop();
|
||||
context.router.maybePop<Playlist>(
|
||||
await ref.read(playlistProvider(playlistId ?? "").future),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,23 @@ class PlaylistNotifier extends FamilyAsyncNotifier<Playlist, String> {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> addTracks(List<String> trackIds, [ValueChanged? onError]) async {
|
||||
try {
|
||||
if (state.value == null) return;
|
||||
|
||||
final spotify = ref.read(spotifyProvider);
|
||||
|
||||
await spotify.playlists.addTracks(
|
||||
trackIds.map((id) => "spotify:track:$id").toList(),
|
||||
state.value!.id!,
|
||||
);
|
||||
} catch (e, stack) {
|
||||
onError?.call(e);
|
||||
AppLogger.reportError(e, stack);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final playlistProvider =
|
||||
|
Loading…
Reference in New Issue
Block a user