15.08 Get & Apply the LocalStorage Settings on App Load

This commit is contained in:
Fredrick W Warren 2021-02-12 07:44:17 -08:00
parent 7443c2cf6a
commit 5f9b395ecc
2 changed files with 18 additions and 1 deletions

View File

@ -4,8 +4,16 @@
</div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
name: 'App'
name: 'App',
methods: {
...mapActions('settings', ['getSettings'])
},
mounted () {
this.getSettings()
}
}
</script>

View File

@ -13,6 +13,9 @@ const mutations = {
},
setShowTasksInOnelist (state, value) {
state.settings.showTasksInOnelist = value
},
setSettings (state, value) {
Object.assign(state.settings, value)
}
}
@ -27,6 +30,12 @@ const actions = {
},
saveSettings ({ state }) {
LocalStorage.set('settings', state.settings)
},
getSettings ({ commit }) {
const settings = LocalStorage.getItem('settings')
if (settings) {
commit('setSettings', settings)
}
}
}