From 58e7f80fb68807827625a0c42b3a357fddea6a21 Mon Sep 17 00:00:00 2001 From: Roberto Tonino Date: Wed, 11 Aug 2021 15:23:41 +0200 Subject: [PATCH] fix: favorites behaviour when editing spotify credentials --- src/app.js | 8 ++++++- src/components/pages/Favorites.vue | 2 +- src/components/pages/Settings.vue | 13 +++++++----- src/constants.js | 4 ++++ src/store/modules/login.js | 32 ++++++++++++++++++++++++++-- src/use/favorites.js | 34 ++++++++++++++++++------------ 6 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 src/constants.js diff --git a/src/app.js b/src/app.js index 1215862..1618448 100644 --- a/src/app.js +++ b/src/app.js @@ -25,6 +25,7 @@ import { fetchData, postToServer } from '@/utils/api' import { toast } from '@/utils/toasts' import { isValidURL } from '@/utils/utils' import { sendAddToQueue } from '@/utils/downloads' +import { SPOTIFY_STATUS } from '@/constants' /* ===== App initialization ===== */ async function startApp() { @@ -36,9 +37,14 @@ async function startApp() { }).$mount('#app') const connectResponse = await (await fetch('connect')).json() - if (!connectResponse.deezerAvailable) document.getElementById('deezer_not_available').classList.remove('hide') + const spotifyStatus = connectResponse.spotifyEnabled ? SPOTIFY_STATUS.ENABLED : SPOTIFY_STATUS.DISABLED + + if (!connectResponse.deezerAvailable) { + document.getElementById('deezer_not_available').classList.remove('hide') + } store.dispatch('setAppInfo', connectResponse.update).catch(console.error) + store.dispatch('setSpotifyStatus', spotifyStatus).catch(console.error) let arl = localStorage.getItem('arl') const accessToken = localStorage.getItem('accessToken') diff --git a/src/components/pages/Favorites.vue b/src/components/pages/Favorites.vue index fd738ae..55a5d7b 100644 --- a/src/components/pages/Favorites.vue +++ b/src/components/pages/Favorites.vue @@ -198,7 +198,7 @@ export default defineComponent({ refreshFavorites } = useFavorites() - refreshFavorites({ isInitial: true }) + refreshFavorites({ isInitial: true }).catch(console.error) watch(isRefreshingFavorites, (newVal, oldVal) => { // If oldVal is true and newOne is false, it means that a refreshing has just terminated diff --git a/src/components/pages/Settings.vue b/src/components/pages/Settings.vue index 669ed2f..b32d70b 100644 --- a/src/components/pages/Settings.vue +++ b/src/components/pages/Settings.vue @@ -723,7 +723,7 @@