Fix notices not disappearing on their own

This commit is contained in:
Henry Jameson 2022-03-27 12:21:33 +03:00
parent e4c804fac0
commit 9ac7046521

View file

@ -106,7 +106,7 @@ const interfaceMod = {
commit('openSettingsModal') commit('openSettingsModal')
}, },
pushGlobalNotice ( pushGlobalNotice (
{ commit, dispatch }, { commit, dispatch, state },
{ {
messageKey, messageKey,
messageArgs = {}, messageArgs = {},
@ -118,11 +118,14 @@ const interfaceMod = {
messageArgs, messageArgs,
level level
} }
if (timeout) {
setTimeout(() => dispatch('removeGlobalNotice', notice), timeout)
}
commit('pushGlobalNotice', notice) commit('pushGlobalNotice', notice)
return notice // Adding a new element to array wraps it in a Proxy, which breaks the comparison
// TODO: Generate UUID or something instead or relying on !== operator?
const newNotice = state.globalNotices[state.globalNotices.length - 1]
if (timeout) {
setTimeout(() => dispatch('removeGlobalNotice', newNotice), timeout)
}
return newNotice
}, },
removeGlobalNotice ({ commit }, notice) { removeGlobalNotice ({ commit }, notice) {
commit('removeGlobalNotice', notice) commit('removeGlobalNotice', notice)