impl starring everywhere

This commit is contained in:
austinried
2021-08-10 09:42:20 +09:00
parent 0a3d542156
commit 075286e939
6 changed files with 121 additions and 62 deletions

View File

@@ -39,18 +39,23 @@ export const usePlaylistWithSongs = (id: string) => {
}
export const useStarred = (id: string, type: string) => {
const starred = useStore(
return useStore(
useCallback(
(state: Store) => {
if (!(type in state.starred)) {
return false
switch (type) {
case 'song':
return state.starredSongs[id]
case 'album':
return state.starredAlbums[id]
case 'artist':
return state.starredArtists[id]
default:
return false
}
return !!state.starred[type][id]
},
[type, id],
),
)
return starred
}
export const useCoverArtUri = () => {