mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-06 15:39:41 +00:00
Compare commits
1 Commits
4bd598e82b
...
77ee387b00
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77ee387b00 |
@ -101,17 +101,11 @@ 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<Playlist>(
|
||||
await ref.read(playlistProvider(playlistId ?? "").future),
|
||||
);
|
||||
context.router.maybePop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,23 +98,6 @@ 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