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
|
const apiCall = like ? API.addLikedSong : API.removeLikedSong
|
||||||
|
|
||||||
return apiCall(songId).then(() => {
|
return apiCall(songId).then(() => {
|
||||||
queryClient.invalidateQueries('liked songs')
|
queryClient.invalidateQueries({ queryKey: ['liked songs'] })
|
||||||
queryClient.invalidateQueries('songs')
|
queryClient.invalidateQueries({ queryKey: ['songs'] })
|
||||||
queryClient.invalidateQueries([songId])
|
queryClient.invalidateQueries({ queryKey: [songId] })
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
<<<<<<< HEAD
|
|
||||||
import { Center, useBreakpointValue, useTheme } from 'native-base';
|
|
||||||
=======
|
|
||||||
import { Center, Text, Toast, 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 { useWindowDimensions } from 'react-native';
|
||||||
import {
|
import {
|
||||||
TabView,
|
TabView,
|
||||||
@@ -28,6 +24,7 @@ export const FavoritesMusic = () => {
|
|||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const likedSongs = useQuery(API.getLikedSongs(['artist', 'SongHistory']));
|
const likedSongs = useQuery(API.getLikedSongs(['artist', 'SongHistory']));
|
||||||
const { mutate } = useLikeSongMutation();
|
const { mutate } = useLikeSongMutation();
|
||||||
|
const { mutateAsync } = useLikeSongMutation();
|
||||||
|
|
||||||
const musics =
|
const musics =
|
||||||
likedSongs.data?.map((x) => ({
|
likedSongs.data?.map((x) => ({
|
||||||
@@ -38,8 +35,7 @@ export const FavoritesMusic = () => {
|
|||||||
bestScore: x.song.bestScore,
|
bestScore: x.song.bestScore,
|
||||||
liked: true,
|
liked: true,
|
||||||
onLike: () => {
|
onLike: () => {
|
||||||
Toast.show({ description: 'aaaaaaa' })
|
mutateAsync({ songId: x.song.id, like: false }).then(() => likedSongs.refetch());
|
||||||
mutate({ songId: x.id, like: false })
|
|
||||||
},
|
},
|
||||||
onPlay: () => navigation.navigate('Play', { songId: x.song.id }),
|
onPlay: () => navigation.navigate('Play', { songId: x.song.id }),
|
||||||
})) ?? [];
|
})) ?? [];
|
||||||
|
|||||||
Reference in New Issue
Block a user