Skip to content

Commit

Permalink
Merge pull request #26415 from storybookjs/norbert/optimize-clear-not…
Browse files Browse the repository at this point in the history
…ification

Core: Optimize clearNotification
  • Loading branch information
kasperpeulen authored Mar 12, 2024
2 parents 7dd433d + ac63ab2 commit 0402f64
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 0402f64

Please sign in to comment.