change storage error one-off into a global notice system

This commit is contained in:
Shpuld Shpuldson 2020-07-02 10:40:41 +03:00
parent 0997e5ff66
commit 1293bec77e
8 changed files with 167 additions and 40 deletions

View file

@ -62,14 +62,14 @@ const persistedStateOptions = {
};
(async () => {
let persistedState
let storageError = 'none'
let storageError = false
const plugins = [pushNotifications]
try {
persistedState = await createPersistedState(persistedStateOptions)
const persistedState = await createPersistedState(persistedStateOptions)
plugins.push(persistedState)
} catch (e) {
console.error(e)
storageError = 'show'
persistedState = _ => _
storageError = true
}
const store = new Vuex.Store({
modules: {
@ -93,11 +93,13 @@ const persistedStateOptions = {
polls: pollsModule,
postStatus: postStatusModule
},
plugins: [persistedState, pushNotifications],
plugins,
strict: false // Socket modifies itself, let's ignore this for now.
// strict: process.env.NODE_ENV !== 'production'
})
store.dispatch('setStorageError', storageError)
if (storageError) {
store.dispatch('pushGlobalNotice', { messageKey: 'errors.storage_unavailable', level: 'error' })
}
afterStoreSetup({ store, i18n })
})()