fix: spotify user not being edited in the store when saving settings

This commit is contained in:
Roberto Tonino 2021-08-11 11:43:30 +02:00
parent 4687db60cf
commit 6feb972bc6
2 changed files with 14 additions and 3 deletions

View File

@ -723,9 +723,10 @@
</template> </template>
<script> <script>
import { mapActions, mapGetters } from 'vuex' import { mapActions, mapGetters, mapMutations } from 'vuex'
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import TemplateVariablesList from '@components/settings/TemplateVariablesList.vue'
import { getSettingsData } from '@/data/settings' import { getSettingsData } from '@/data/settings'
import { trackTemplateVariables } from '@/data/file-templates' import { trackTemplateVariables } from '@/data/file-templates'
@ -735,7 +736,6 @@ import { flags } from '@/utils/flags'
import { copyToClipboard } from '@/utils/utils' import { copyToClipboard } from '@/utils/utils'
import BaseAccordion from '@/components/globals/BaseAccordion.vue' import BaseAccordion from '@/components/globals/BaseAccordion.vue'
import TemplateVariablesList from '@components/settings/TemplateVariablesList.vue'
import { fetchData, postToServer } from '@/utils/api' import { fetchData, postToServer } from '@/utils/api'
import { getFormItem } from '@/utils/forms' import { getFormItem } from '@/utils/forms'
import { useLogs } from '@/use/logs' import { useLogs } from '@/use/logs'
@ -860,6 +860,9 @@ export default {
dispatchLogout: 'logout', dispatchLogout: 'logout',
dispatchLogin: 'login' dispatchLogin: 'login'
}), }),
...mapMutations({
setSpotifyUserId: 'SET_SPOTIFY_USER_ID'
}),
onTemplateVariableClick(templateName) { onTemplateVariableClick(templateName) {
copyToClipboard(templateName) copyToClipboard(templateName)
toast(`Copied ${templateName} to clipboard!`) toast(`Copied ${templateName} to clipboard!`)
@ -895,10 +898,11 @@ export default {
let changed = false let changed = false
if (this.lastUser != this.spotifyUser) { if (this.lastUser !== this.spotifyUser) {
// force cloning without linking // force cloning without linking
this.lastUser = (' ' + this.spotifyUser).slice(1) this.lastUser = (' ' + this.spotifyUser).slice(1)
localStorage.setItem('spotifyUser', this.lastUser) localStorage.setItem('spotifyUser', this.lastUser)
this.setSpotifyUserId(this.lastUser)
changed = true changed = true
} }

View File

@ -107,6 +107,13 @@ const mutations = {
const clientMode = state.clientMode const clientMode = state.clientMode
Object.assign(state, getDefaultState()) Object.assign(state, getDefaultState())
state.clientMode = clientMode state.clientMode = clientMode
},
SET_SPOTIFY_USER_ID(state, newSpotifyUserId) {
console.log('setting spotify user', { newSpotifyUserId })
state.spotifyUser = {
...state.spotifyUser,
id: newSpotifyUserId
}
} }
} }