export default { namespaced: true, state: { alerts: [], snackbars: [], newAlertCount: 0 }, getters: { nextSnackbar (state) { if (state.snackbars) return state.snackbars[0] else return null } }, mutations: { shiftSnackbars (state) { state.snackbars.shift() }, newSnackbar (state, data) { state.snackbars.push(data) }, newAlert (state, data) { data.show = true state.newAlertCount++ state.alerts.unshift(data) }, removeAlert (state, id) { const a = state.alerts.find(el => el.id === id) a.show = false setTimeout(function () { var index = state.alerts.indexOf(a) state.alerts.splice(index, 1) if (index < state.newAlertCount && index >= 0) state.newAlertCount-- }, 200) }, resetNewAlertCount (state) { state.newAlertCount = 0 } } }