0 ? notificationStyles.badge : ''
+ reducedNotifications?.length > 0 ? notificationStyles.badge : ''
}
/>
@@ -77,7 +78,7 @@ export function NotificationsMenu() {
Notifications
- {userNotifications?.length > 0 && (
+ {reducedNotifications?.length > 0 && (
- {userNotifications?.length > 0 ? (
+ {reducedNotifications?.length > 0 ? (
<>
- {userNotifications.map((notification) => (
+ {reducedNotifications.map((notification) => (
()(
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,
},
};
});