feat: added global caching for settings, default settings and credentials
This commit is contained in:
31
src/store/modules/defaultSettings.js
Normal file
31
src/store/modules/defaultSettings.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
const state = {}
|
||||
|
||||
const actions = {
|
||||
setDefaultSettings({ commit }, payload) {
|
||||
for (const settingName in payload) {
|
||||
if (!payload.hasOwnProperty(settingName)) return
|
||||
|
||||
const settingValue = payload[settingName]
|
||||
commit('SET_UNKNOWN_DEFAULT_SETTING', { settingName, settingValue })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getters = {
|
||||
getDefaultSettings: state => state
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_UNKNOWN_DEFAULT_SETTING(state, payload) {
|
||||
Vue.set(state, payload.settingName, payload.settingValue)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
actions,
|
||||
getters,
|
||||
mutations
|
||||
}
|
||||
31
src/store/modules/spotifyCredentials.js
Normal file
31
src/store/modules/spotifyCredentials.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const state = {
|
||||
clientId: '',
|
||||
clientSecret: ''
|
||||
}
|
||||
|
||||
const actions = {
|
||||
setCredentials({ commit }, payload) {
|
||||
commit('SET_CLIENT_ID', payload.clientId)
|
||||
commit('SET_CLIENT_SECRET', payload.clientSecret)
|
||||
}
|
||||
}
|
||||
|
||||
const getters = {
|
||||
getCredentials: state => state
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_CLIENT_ID(state, payload) {
|
||||
state.clientId = payload
|
||||
},
|
||||
SET_CLIENT_SECRET(state, payload) {
|
||||
state.clientSecret = payload
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
Reference in New Issue
Block a user