From 352a59c291ee26dd76604219a2a0adc40c00f393 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Wed, 29 Dec 2021 18:46:11 +0100 Subject: [PATCH] fixed loved tracks download --- src/components/pages/Favorites.vue | 12 +++++++++--- src/lang/en.js | 3 ++- src/use/favorites.js | 5 ++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/pages/Favorites.vue b/src/components/pages/Favorites.vue index 5e849e6..36de42b 100644 --- a/src/components/pages/Favorites.vue +++ b/src/components/pages/Favorites.vue @@ -194,6 +194,7 @@ export default defineComponent({ favoriteSpotifyPlaylists, favoritePlaylists, favoriteTracks, + lovedTracksPlaylist, isRefreshingFavorites, refreshFavorites } = useFavorites() @@ -217,6 +218,7 @@ export default defineComponent({ artists: favoriteArtists, playlists: favoritePlaylists, spotifyPlaylists: favoriteSpotifyPlaylists, + lovedTracks: lovedTracksPlaylist, refreshFavorites, isRefreshingFavorites } @@ -236,9 +238,12 @@ export default defineComponent({ const toDownload = this.getActiveRelease() if (this.activeTab === 'track') { - const lovedTracks = this.getLovedTracksPlaylist() - - sendAddToQueue(lovedTracks.link) + if (this.lovedTracks){ + sendAddToQueue(this.lovedTracks) + } else { + const lovedTracks = this.getLovedTracksPlaylist() + sendAddToQueue(lovedTracks.link) + } } else { sendAddToQueue(aggregateDownloadLinks(toDownload)) } @@ -290,6 +295,7 @@ export default defineComponent({ if (lovedTracks.length !== 0) { return lovedTracks[0] } else { + toast(this.$t('toasts.noLovedPlaylist'), 'warning', true) throw new Error('No loved tracks playlist!') } } diff --git a/src/lang/en.js b/src/lang/en.js index 8ee4d44..cfd480a 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -215,7 +215,8 @@ const en = { loginNeededToDownload: 'You need to log in to download tracks!', deezerNotAvailable: 'Deezer is not available in your country. You should use a VPN.', startGeneratingItems: 'Processing {n} items...', - finishGeneratingItems: 'Generated {n} items.' + finishGeneratingItems: 'Generated {n} items.', + noLovedPlaylist: 'No loved tracks playlist!' }, settings: { title: 'Settings', diff --git a/src/use/favorites.js b/src/use/favorites.js index 141e196..43cab69 100644 --- a/src/use/favorites.js +++ b/src/use/favorites.js @@ -9,12 +9,13 @@ const favoriteAlbums = ref([]) const favoriteSpotifyPlaylists = ref([]) const favoritePlaylists = ref([]) const favoriteTracks = ref([]) +const lovedTracksPlaylist = ref('') const isLoggedWithSpotify = computed(() => store.getters.isLoggedWithSpotify) const isRefreshingFavorites = ref(false) const setAllFavorites = data => { - const { tracks, albums, artists, playlists } = data + const { tracks, albums, artists, playlists, lovedTracks } = data isRefreshingFavorites.value = false @@ -22,6 +23,7 @@ const setAllFavorites = data => { favoriteAlbums.value = albums favoritePlaylists.value = playlists favoriteTracks.value = tracks + lovedTracksPlaylist.value = lovedTracks } const setSpotifyPlaylists = response => { @@ -59,6 +61,7 @@ export const useFavorites = () => ({ favoriteSpotifyPlaylists, favoritePlaylists, favoriteTracks, + lovedTracksPlaylist, isRefreshingFavorites, refreshFavorites })