fix: correctly resetting favorites according to spotify login status
This commit is contained in:
parent
6feb972bc6
commit
5f5301b6b8
@ -11,7 +11,18 @@ const favoriteTracks = ref([])
|
|||||||
|
|
||||||
const isRefreshingFavorites = ref(false)
|
const isRefreshingFavorites = ref(false)
|
||||||
|
|
||||||
function refreshFavorites({ isInitial = false }) {
|
const setAllFavorites = data => {
|
||||||
|
const { tracks, albums, artists, playlists } = data
|
||||||
|
|
||||||
|
isRefreshingFavorites.value = false
|
||||||
|
|
||||||
|
favoriteArtists.value = artists
|
||||||
|
favoriteAlbums.value = albums
|
||||||
|
favoritePlaylists.value = playlists
|
||||||
|
favoriteTracks.value = tracks
|
||||||
|
}
|
||||||
|
|
||||||
|
const refreshFavorites = ({ isInitial = false }) => {
|
||||||
if (!isInitial) {
|
if (!isInitial) {
|
||||||
isRefreshingFavorites.value = true
|
isRefreshingFavorites.value = true
|
||||||
}
|
}
|
||||||
@ -26,28 +37,17 @@ function refreshFavorites({ isInitial = false }) {
|
|||||||
favoriteSpotifyPlaylists.value = spotifyPlaylists
|
favoriteSpotifyPlaylists.value = spotifyPlaylists
|
||||||
})
|
})
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
|
} else {
|
||||||
|
favoriteSpotifyPlaylists.value = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAllFavorites(data) {
|
export const useFavorites = () => ({
|
||||||
const { tracks, albums, artists, playlists } = data
|
favoriteArtists,
|
||||||
|
favoriteAlbums,
|
||||||
isRefreshingFavorites.value = false
|
favoriteSpotifyPlaylists,
|
||||||
|
favoritePlaylists,
|
||||||
favoriteArtists.value = artists
|
favoriteTracks,
|
||||||
favoriteAlbums.value = albums
|
isRefreshingFavorites,
|
||||||
favoritePlaylists.value = playlists
|
refreshFavorites
|
||||||
favoriteTracks.value = tracks
|
})
|
||||||
}
|
|
||||||
|
|
||||||
export function useFavorites() {
|
|
||||||
return {
|
|
||||||
favoriteArtists,
|
|
||||||
favoriteAlbums,
|
|
||||||
favoriteSpotifyPlaylists,
|
|
||||||
favoritePlaylists,
|
|
||||||
favoriteTracks,
|
|
||||||
isRefreshingFavorites,
|
|
||||||
refreshFavorites
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user