mirror of
https://github.com/Jellify-Music/App.git
synced 2026-04-21 17:18:23 -05:00
that's why this isn't updating
This commit is contained in:
@@ -51,17 +51,39 @@ export default function Playlist({
|
||||
}
|
||||
});
|
||||
|
||||
// If we've got the playlist tracks, set our component state
|
||||
useEffect(() => {
|
||||
if (!isPending && isSuccess)
|
||||
setPlaylistTracks(tracks);
|
||||
}, [
|
||||
isPending,
|
||||
isSuccess
|
||||
])
|
||||
]);
|
||||
|
||||
// Refresh playlist tracks if we've finished editing
|
||||
useEffect(() => {
|
||||
if (!editing)
|
||||
refetch();
|
||||
}, [
|
||||
editing
|
||||
]);
|
||||
|
||||
|
||||
const useUpdatePlaylist = useMutation({
|
||||
mutationFn: ({ playlist, tracks }: { playlist: BaseItemDto, tracks: BaseItemDto[] }) => {
|
||||
return updatePlaylist(playlist.Id!, playlist.Name!, tracks.map(track => track.Id!))
|
||||
},
|
||||
onSuccess: () => {
|
||||
trigger('notificationSuccess');
|
||||
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [QueryKeys.ItemTracks, playlist.Id, false]
|
||||
})
|
||||
},
|
||||
onError: () => {
|
||||
trigger('notificationError');
|
||||
|
||||
setPlaylistTracks(tracks ?? []);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user