feat: simple but efficient cache of home data
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import Vuex from 'vuex'
|
||||
import Vue from 'vue'
|
||||
|
||||
import home from '@/store/modules/home'
|
||||
// import home from '@/store/modules/home'
|
||||
import settings from '@/store/modules/settings'
|
||||
import defaultSettings from '@/store/modules/defaultSettings'
|
||||
import spotifyCredentials from '@/store/modules/spotifyCredentials'
|
||||
@@ -17,7 +17,7 @@ Vue.use(Vuex)
|
||||
// Create store
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
home,
|
||||
// home,
|
||||
settings,
|
||||
defaultSettings,
|
||||
spotifyCredentials,
|
||||
|
||||
@@ -22,12 +22,10 @@ const actions = {
|
||||
commit('SET_FAVORITES_ARTISTS', { index, data: artist })
|
||||
})
|
||||
|
||||
// dispatch('setFavoritesTracks', payload.tracks)
|
||||
dispatch('setFavoritesTracks', payload.tracks)
|
||||
},
|
||||
setFavoritesTracks({ commit }, payload) {
|
||||
payload.forEach((track, index) => {
|
||||
commit('SET_FAVORITES_TRACKS', { index, data: track })
|
||||
})
|
||||
commit('SET_FAVORITES_TRACKS', payload)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +48,12 @@ const mutations = {
|
||||
Vue.set(state.playlists, payload.index, payload.data)
|
||||
},
|
||||
SET_FAVORITES_TRACKS: (state, payload) => {
|
||||
Vue.set(state.tracks, payload.index, payload.data)
|
||||
if (typeof payload !== 'string') {
|
||||
console.error('[deemix] Not setting the favorites tracks because they are not in string format')
|
||||
return
|
||||
}
|
||||
|
||||
state.tracks = payload
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user