Cross-tab syncing

This commit is contained in:
root
2021-11-12 08:34:51 +05:30
parent 1d08a3cee1
commit 55c3854c22
3 changed files with 27 additions and 6 deletions
+11 -2
View File
@@ -122,6 +122,15 @@ const AuthenticationStore = {
}
}
export {
AuthenticationStore
function initializeAuthEvents (store) {
window.addEventListener('storage', (storageEv) => {
if (storageEv.key === 'AUTH') {
store.commit('auth/replaceAuth', JSON.parse(storageEv.newValue))
}
})
}
export {
AuthenticationStore,
initializeAuthEvents
}
+5 -2
View File
@@ -1,8 +1,8 @@
import Vue from 'vue'
import Vuex from 'vuex'
import { PrefsStore } from '@/store/prefs-store'
import { AuthenticationStore } from '@/store/authentication-store'
import { PrefsStore, initializePrefEvents } from '@/store/prefs-store'
import { AuthenticationStore, initializeAuthEvents } from '@/store/authentication-store'
Vue.use(Vuex)
@@ -13,4 +13,7 @@ const store = new Vuex.Store({
}
})
initializePrefEvents(store)
initializeAuthEvents(store)
export default store
+11 -2
View File
@@ -77,6 +77,15 @@ const PrefsStore = {
}
}
export {
PrefsStore
function initializePrefEvents (store) {
window.addEventListener('storage', (storageEv) => {
if (storageEv.key === 'PREFERENCES') {
store.commit('prefs/replacePrefs', JSON.parse(storageEv.newValue))
}
})
}
export {
PrefsStore,
initializePrefEvents
}