like state
This commit is contained in:
@@ -111,7 +111,10 @@ const SearchView = (props: RouteProps<{}>) => {
|
||||
|
||||
if (userQuery.isSuccess) {
|
||||
result =
|
||||
rawResult.data?.map((song) => ({
|
||||
rawResult.data?.map((song) => {
|
||||
const isLiked = likedSongs.data?.some((x) => x.songId == song.id) ?? false;
|
||||
|
||||
return {
|
||||
artist:
|
||||
artistsQuery.data?.find((artist) => artist.id == song?.artist?.id)?.name ??
|
||||
'unknown artist',
|
||||
@@ -120,12 +123,15 @@ const SearchView = (props: RouteProps<{}>) => {
|
||||
level: song?.difficulties.chordcomplexity,
|
||||
lastScore: song?.lastScore,
|
||||
bestScore: song?.bestScore,
|
||||
liked: likedSongs.data?.some((x) => x.songId == song.id) ?? false,
|
||||
liked: isLiked,
|
||||
onLike: () => {
|
||||
mutateAsync({ songId: song.id, like: false }).then(() => likedSongs.refetch());
|
||||
mutateAsync({ songId: song.id, like: !isLiked }).then(() =>
|
||||
likedSongs.refetch()
|
||||
);
|
||||
},
|
||||
onPlay: () => navigation.navigate('Play', { songId: song.id }),
|
||||
})) ?? [];
|
||||
};
|
||||
}) ?? [];
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user