1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-09 07:45:22 +02:00

fix(notifications): limit only in header [EE-4815] (#8579)

Co-authored-by: testa113 <testa113>
This commit is contained in:
Ali 2023-03-03 15:08:15 +13:00 committed by GitHub
parent fd916bc8a2
commit 07df4b1591
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 13 deletions

View file

@ -20,22 +20,15 @@ export const notificationsStore = create<NotificationsState>()(
userNotifications: {},
addNotification: (userId: number, notification: ToastNotification) => {
set((state) => {
const currentUserNotifications =
state.userNotifications[userId] || [];
// keep the new notification at the start of the list, so sorting by newest time isn't required
const newUserNotifications = [
notification,
...currentUserNotifications,
...(state.userNotifications[userId] || []),
];
const maxNotifications = 50;
const reducedNotifications = newUserNotifications.slice(
0,
maxNotifications
);
return {
userNotifications: {
...state.userNotifications,
[userId]: reducedNotifications,
[userId]: newUserNotifications,
},
};
});