Front: MusicView: Fix Wrong Mutation
This commit is contained in:
committed by
Clément Le Bihan
parent
962cf58e77
commit
c5124fa6ad
@@ -11,9 +11,9 @@ export const useLikeSongMutation = () => {
|
||||
const apiCall = like ? API.addLikedSong : API.removeLikedSong
|
||||
|
||||
return apiCall(songId).then(() => {
|
||||
queryClient.invalidateQueries('liked songs')
|
||||
queryClient.invalidateQueries('songs')
|
||||
queryClient.invalidateQueries([songId])
|
||||
queryClient.invalidateQueries({ queryKey: ['liked songs'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['songs'] })
|
||||
queryClient.invalidateQueries({ queryKey: [songId] })
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
import React from 'react';
|
||||
<<<<<<< HEAD
|
||||
import { Center, useBreakpointValue, useTheme } from 'native-base';
|
||||
=======
|
||||
import { Center, Text, Toast, useBreakpointValue, useTheme } from 'native-base';
|
||||
>>>>>>> 06cfa56 (Front: Use Mutations to update 'liked' state)
|
||||
import { useWindowDimensions } from 'react-native';
|
||||
import {
|
||||
TabView,
|
||||
@@ -28,6 +24,7 @@ export const FavoritesMusic = () => {
|
||||
const navigation = useNavigation();
|
||||
const likedSongs = useQuery(API.getLikedSongs(['artist', 'SongHistory']));
|
||||
const { mutate } = useLikeSongMutation();
|
||||
const { mutateAsync } = useLikeSongMutation();
|
||||
|
||||
const musics =
|
||||
likedSongs.data?.map((x) => ({
|
||||
@@ -38,8 +35,7 @@ export const FavoritesMusic = () => {
|
||||
bestScore: x.song.bestScore,
|
||||
liked: true,
|
||||
onLike: () => {
|
||||
Toast.show({ description: 'aaaaaaa' })
|
||||
mutate({ songId: x.id, like: false })
|
||||
mutateAsync({ songId: x.song.id, like: false }).then(() => likedSongs.refetch());
|
||||
},
|
||||
onPlay: () => navigation.navigate('Play', { songId: x.song.id }),
|
||||
})) ?? [];
|
||||
|
||||
Reference in New Issue
Block a user