From 9ac7046521d9cffcff1e2d846b1158d32c01ed85 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 27 Mar 2022 12:21:33 +0300 Subject: [PATCH] Fix notices not disappearing on their own --- src/modules/interface.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/modules/interface.js b/src/modules/interface.js index 6509386a..17277331 100644 --- a/src/modules/interface.js +++ b/src/modules/interface.js @@ -106,7 +106,7 @@ const interfaceMod = { commit('openSettingsModal') }, pushGlobalNotice ( - { commit, dispatch }, + { commit, dispatch, state }, { messageKey, messageArgs = {}, @@ -118,11 +118,14 @@ const interfaceMod = { messageArgs, level } - if (timeout) { - setTimeout(() => dispatch('removeGlobalNotice', notice), timeout) - } 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) { commit('removeGlobalNotice', notice)