Skip to content

Commit

Permalink
only setState when the notification was found
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Mar 11, 2024
1 parent bfa0570 commit ac63ab2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions code/lib/manager-api/src/modules/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}
},
};
Expand Down

0 comments on commit ac63ab2

Please sign in to comment.