-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added box if band/artist stopped performing (#27)
* refactor: used cached version of the search * feat: added box if bands stopped playing * refactor: improved ui tracks
- Loading branch information
Showing
6 changed files
with
114 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import useSWR from "swr"; | ||
import { ArtistInfo } from "types"; | ||
import { fetcher } from "utils/api"; | ||
|
||
export type SearchResults = { | ||
artists: ArtistInfo[]; | ||
}; | ||
|
||
export const useSearchArtistByName = (searchTerm: string | undefined) => { | ||
const { data, error, isLoading } = useSWR( | ||
searchTerm && searchTerm.length > 1 | ||
? `https://musicbrainz.org/ws/2/artist?query=${encodeURIComponent(searchTerm)}&fmt=json` | ||
: null, | ||
fetcher<SearchResults>, | ||
{ | ||
dedupingInterval: 300, | ||
revalidateOnFocus: false, | ||
revalidateOnReconnect: false, | ||
}, | ||
); | ||
|
||
return { | ||
data, | ||
isLoading, | ||
isError: error, | ||
}; | ||
}; | ||
|
||
export const useGetArtist = (mbid: string | undefined) => { | ||
const { data, error, isLoading } = useSWR( | ||
mbid ? `https://musicbrainz.org/ws/2/artist/${mbid}?fmt=json` : null, | ||
fetcher<ArtistInfo>, | ||
{ | ||
revalidateOnFocus: false, | ||
revalidateOnReconnect: false, | ||
}, | ||
); | ||
|
||
return { | ||
artist: data, | ||
isLoading, | ||
isError: error, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters