fix artist name
This commit is contained in:
@@ -93,7 +93,7 @@ const MusicListNoOpti = ({ list }: { list: any[] }) => {
|
|||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
const SearchView = (props: RouteProps<{}>) => {
|
const SearchView = (props: RouteProps<{}>) => {
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const artists = useQuery(API.getAllArtists());
|
const artistsQuery = useQuery(API.getAllArtists());
|
||||||
const [searchQuery, setSearchQuery] = React.useState({} as searchProps);
|
const [searchQuery, setSearchQuery] = React.useState({} as searchProps);
|
||||||
const rawResult = useQuery(API.searchSongs(searchQuery));
|
const rawResult = useQuery(API.searchSongs(searchQuery));
|
||||||
const userQuery = useQuery(API.getUserInfo());
|
const userQuery = useQuery(API.getUserInfo());
|
||||||
@@ -102,7 +102,7 @@ const SearchView = (props: RouteProps<{}>) => {
|
|||||||
|
|
||||||
let result: any[] = [];;
|
let result: any[] = [];;
|
||||||
|
|
||||||
if (userQuery.isLoading || likedSongs.isLoading || userQuery.isLoading) {
|
if (userQuery.isLoading || likedSongs.isLoading || artistsQuery.isLoading) {
|
||||||
return <LoadingComponent />;
|
return <LoadingComponent />;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,14 +114,14 @@ const SearchView = (props: RouteProps<{}>) => {
|
|||||||
result =
|
result =
|
||||||
rawResult.data?.map((song) => ({
|
rawResult.data?.map((song) => ({
|
||||||
artist:
|
artist:
|
||||||
artists.data?.find((artist) => artist.id === song?.artist?.id)?.name ??
|
artistsQuery.data?.find((artist) => artist.id == song?.artist?.id)?.name ??
|
||||||
'unknown artist',
|
'unknown artist',
|
||||||
song: song?.name,
|
song: song?.name,
|
||||||
image: song?.cover,
|
image: song?.cover,
|
||||||
level: song?.difficulties.chordcomplexity,
|
level: song?.difficulties.chordcomplexity,
|
||||||
lastScore: song?.lastScore,
|
lastScore: song?.lastScore,
|
||||||
bestScore: song?.bestScore,
|
bestScore: song?.bestScore,
|
||||||
liked: likedSongs.data?.some(x => x.songId === song.id) ?? false,
|
liked: likedSongs.data?.some(x => x.songId == song.id) ?? false,
|
||||||
onLike: () => {
|
onLike: () => {
|
||||||
mutateAsync({ songId: song.id, like: false }).then(() => likedSongs.refetch());
|
mutateAsync({ songId: song.id, like: false }).then(() => likedSongs.refetch());
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user