Ensure selected locale is not reset to browser default when refreshing app

This commit is contained in:
Eliot Berriot 2019-09-11 12:30:31 +02:00
parent 39f6f51e4e
commit 7f106d21c4
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
4 changed files with 7 additions and 2 deletions

View File

@ -0,0 +1 @@
Ensure selected locale is not reset to browser default when refreshing app

View File

@ -71,7 +71,9 @@ export default {
created () {
this.openWebsocket()
let self = this
this.autodetectLanguage()
if (!this.$store.state.ui.selectedLanguage) {
this.autodetectLanguage()
}
setInterval(() => {
// used to redraw ago dates every minute
self.$store.commit('ui/computeLastDate')

View File

@ -40,7 +40,7 @@ export default new Vuex.Store({
}),
createPersistedState({
key: 'ui',
paths: ['ui.currentLanguage', 'ui.momentLocale', 'ui.theme']
paths: ['ui.currentLanguage', 'ui.selectedLanguage', 'ui.momentLocale', 'ui.theme']
}),
createPersistedState({
key: 'radios',

View File

@ -5,6 +5,7 @@ export default {
namespaced: true,
state: {
currentLanguage: 'en_US',
selectedLanguage: false,
momentLocale: 'en',
lastDate: new Date(),
maxMessages: 100,
@ -33,6 +34,7 @@ export default {
},
currentLanguage: (state, value) => {
state.currentLanguage = value
state.selectedLanguage = true
},
momentLocale: (state, value) => {
state.momentLocale = value