aboutsummaryrefslogtreecommitdiff
path: root/src/modules/interface.js
diff options
context:
space:
mode:
authorShpuld Shpuldson <shp@cock.li>2020-07-02 10:40:41 +0300
committerShpuld Shpuldson <shp@cock.li>2020-07-02 10:40:41 +0300
commit1293bec77e5137acf64d3536c286f8ba3df284f4 (patch)
treedd95f0f93a0e54c3215491b98e2dac871fe102ff /src/modules/interface.js
parent0997e5ff668a57d58002ec646f698c5503f66c35 (diff)
change storage error one-off into a global notice system
Diffstat (limited to 'src/modules/interface.js')
-rw-r--r--src/modules/interface.js33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/modules/interface.js b/src/modules/interface.js
index 4b5b5b5d..338ef651 100644
--- a/src/modules/interface.js
+++ b/src/modules/interface.js
@@ -8,14 +8,14 @@ const defaultState = {
noticeClearTimeout: null,
notificationPermission: null
},
- storageError: 'none',
browserSupport: {
cssFilter: window.CSS && window.CSS.supports && (
window.CSS.supports('filter', 'drop-shadow(0 0)') ||
window.CSS.supports('-webkit-filter', 'drop-shadow(0 0)')
)
},
- mobileLayout: false
+ mobileLayout: false,
+ globalNotices: []
}
const interfaceMod = {
@@ -60,8 +60,11 @@ const interfaceMod = {
state.settingsModalLoaded = true
}
},
- setStorageError (state, value) {
- state.storageError = value
+ pushGlobalNotice (state, notice) {
+ state.globalNotices.push(notice)
+ },
+ removeGlobalNotice (state, notice) {
+ state.globalNotices = state.globalNotices.filter(n => n !== notice)
}
},
actions: {
@@ -86,8 +89,26 @@ const interfaceMod = {
togglePeekSettingsModal ({ commit }) {
commit('togglePeekSettingsModal')
},
- setStorageError ({ commit }, value) {
- commit('setStorageError', value)
+ pushGlobalNotice (
+ { commit, dispatch },
+ {
+ messageKey,
+ messageArgs = {},
+ level = 'error',
+ timeout = 0
+ }) {
+ const notice = {
+ messageKey,
+ messageArgs,
+ level
+ }
+ if (timeout) {
+ setTimeout(() => dispatch('removeGlobalNotice', notice), timeout)
+ }
+ commit('pushGlobalNotice', notice)
+ },
+ removeGlobalNotice ({ commit }, notice) {
+ commit('removeGlobalNotice', notice)
}
}
}