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:
parent
fd916bc8a2
commit
07df4b1591
2 changed files with 7 additions and 13 deletions
|
@ -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,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue