From 2eeb6e1785c18c2f0bafcc6ae6fa1ed57fc725ef Mon Sep 17 00:00:00 2001 From: David Buezas Date: Mon, 4 Dec 2023 02:07:53 +0100 Subject: [PATCH] Fix Persistent toasts (#375) When the tab is in the background for long enough, the timeouts pile up and then get all called at once. This resulted in in a stale toastsRef.current array. --- src/contexts/UiContext.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/contexts/UiContext.js b/src/contexts/UiContext.js index ee666f13d..ffbe250d0 100644 --- a/src/contexts/UiContext.js +++ b/src/contexts/UiContext.js @@ -111,8 +111,9 @@ const UiContextProvider = ({ children }) => { } const removeToast = (uids) => { - const removedIds = removeEntriesByIDs(toastsRef.current, uids) - setToasts([...removedIds]) + const remainingIds = removeEntriesByIDs(toastsRef.current, uids) + toastsRef.current = remainingIds + setToasts([...remainingIds]) } const addModal = (newModal) =>