mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
chore(notifications):improve performance [EE-4815] (#8475)
* chore(notifications):improve performance [EE-4815] Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
89dd72b4ac
commit
23f3008500
2 changed files with 27 additions and 29 deletions
|
@ -7,7 +7,6 @@ import {
|
|||
} from '@reach/menu-button';
|
||||
import { UISrefProps, useSref } from '@uirouter/react';
|
||||
import Moment from 'moment';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useStore } from 'zustand';
|
||||
import { AlertCircle, Bell, CheckCircle, Trash2 } from 'lucide-react';
|
||||
|
||||
|
@ -35,23 +34,6 @@ export function NotificationsMenu() {
|
|||
(state) => state.userNotifications[user.Id]
|
||||
);
|
||||
|
||||
if (userNotifications && userNotifications.length > 1) {
|
||||
userNotifications.sort(
|
||||
(a, b) =>
|
||||
new Date(b.timeStamp).getTime() - new Date(a.timeStamp).getTime()
|
||||
);
|
||||
}
|
||||
|
||||
const [badge, setBadge] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (userNotifications?.length > 0) {
|
||||
setBadge(true);
|
||||
} else {
|
||||
setBadge(false);
|
||||
}
|
||||
}, [userNotifications]);
|
||||
|
||||
return (
|
||||
<Menu>
|
||||
<MenuButton
|
||||
|
@ -71,7 +53,11 @@ export function NotificationsMenu() {
|
|||
)}
|
||||
>
|
||||
<Icon icon={Bell} />
|
||||
<span className={badge ? notificationStyles.badge : ''} />
|
||||
<span
|
||||
className={
|
||||
userNotifications?.length > 0 ? notificationStyles.badge : ''
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</MenuButton>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue