From 5cec62d1b18c2b5c411395dbe177575093e60688 Mon Sep 17 00:00:00 2001 From: danis Date: Wed, 6 Sep 2023 16:38:44 +0200 Subject: [PATCH] search view update --- front/API.ts | 1 + front/views/SearchView.tsx | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/front/API.ts b/front/API.ts index 6051267..b9da932 100644 --- a/front/API.ts +++ b/front/API.ts @@ -288,6 +288,7 @@ export default class API { ), }; } + /** * Retrive a song's midi partition * @param songId the id to find the song diff --git a/front/views/SearchView.tsx b/front/views/SearchView.tsx index 108ff54..386d584 100644 --- a/front/views/SearchView.tsx +++ b/front/views/SearchView.tsx @@ -10,6 +10,7 @@ import { SafeAreaView } from 'react-native'; import { Filter } from '../components/SearchBar'; import { ScrollView } from 'native-base'; import { RouteProps } from '../Navigation'; +import LikedSong from '../models/LikedSong'; interface SearchContextType { filter: 'artist' | 'song' | 'genre' | 'all'; @@ -19,6 +20,7 @@ interface SearchContextType { songData: Song[]; artistData: Artist[]; genreData: Genre[]; + favoriteData: LikedSong[]; isLoadingSong: boolean; isLoadingArtist: boolean; isLoadingGenre: boolean; @@ -32,6 +34,7 @@ export const SearchContext = React.createContext({ songData: [], artistData: [], genreData: [], + favoriteData: [], isLoadingSong: false, isLoadingArtist: false, isLoadingGenre: false, @@ -60,6 +63,11 @@ const SearchView = (props: RouteProps) => { { enabled: !!stringQuery } ); + const { isLoading: isLoadingFavorite, data: favoriteData = [] } = useQuery( + API.getLikedSongs(), + { enabled: true } + ) + const updateFilter = (newData: Filter) => { // called when the filter is changed setFilter(newData); @@ -80,6 +88,7 @@ const SearchView = (props: RouteProps) => { songData, artistData, genreData, + favoriteData, isLoadingSong, isLoadingArtist, isLoadingGenre, @@ -96,3 +105,6 @@ const SearchView = (props: RouteProps) => { }; export default SearchView; + + +