From ac63ab2e0ce59333ad01b6815144a866d920622c Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Mon, 11 Mar 2024 14:56:53 +0100 Subject: [PATCH] only setState when the notification was found --- code/lib/manager-api/src/modules/notifications.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/lib/manager-api/src/modules/notifications.ts b/code/lib/manager-api/src/modules/notifications.ts index 83e95d3928ca..3358dd67a241 100644 --- a/code/lib/manager-api/src/modules/notifications.ts +++ b/code/lib/manager-api/src/modules/notifications.ts @@ -37,11 +37,13 @@ export const init: ModuleFn = ({ store }) => { clearNotification: (id) => { const { notifications } = store.getState(); - store.setState({ notifications: notifications.filter((n) => n.id !== id) }); - const notification = notifications.find((n) => n.id === id); - if (notification && notification.onClear) { - notification.onClear({ dismissed: false }); + + if (notification) { + store.setState({ notifications: notifications.filter((n) => n.id !== id) }); + if (notification.onClear) { + notification.onClear({ dismissed: false }); + } } }, };