mirror of
https://gitlab.com/RemixDev/deemix-webui.git
synced 2024-12-29 10:56:05 +00:00
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)
|
||||
|
||||
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) {
|
||||
isRefreshingFavorites.value = true
|
||||
}
|
||||
|
@ -26,28 +37,17 @@ function refreshFavorites({ isInitial = false }) {
|
|||
favoriteSpotifyPlaylists.value = spotifyPlaylists
|
||||
})
|
||||
.catch(console.error)
|
||||
} else {
|
||||
favoriteSpotifyPlaylists.value = []
|
||||
}
|
||||
}
|
||||
|
||||
function setAllFavorites(data) {
|
||||
const { tracks, albums, artists, playlists } = data
|
||||
|
||||
isRefreshingFavorites.value = false
|
||||
|
||||
favoriteArtists.value = artists
|
||||
favoriteAlbums.value = albums
|
||||
favoritePlaylists.value = playlists
|
||||
favoriteTracks.value = tracks
|
||||
}
|
||||
|
||||
export function useFavorites() {
|
||||
return {
|
||||
favoriteArtists,
|
||||
favoriteAlbums,
|
||||
favoriteSpotifyPlaylists,
|
||||
favoritePlaylists,
|
||||
favoriteTracks,
|
||||
isRefreshingFavorites,
|
||||
refreshFavorites
|
||||
}
|
||||
}
|
||||
export const useFavorites = () => ({
|
||||
favoriteArtists,
|
||||
favoriteAlbums,
|
||||
favoriteSpotifyPlaylists,
|
||||
favoritePlaylists,
|
||||
favoriteTracks,
|
||||
isRefreshingFavorites,
|
||||
refreshFavorites
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue