From 2416c91c1a13af1fcafbe92de4ff121755e036c8 Mon Sep 17 00:00:00 2001 From: James Acklin Date: Wed, 11 Jan 2023 08:16:35 -0500 Subject: [PATCH] garden: only show mark as read if >0 unread notifications fixes tloncorp/landscape-apps#1265 --- ui/src/nav/notifications/Notifications.tsx | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/ui/src/nav/notifications/Notifications.tsx b/ui/src/nav/notifications/Notifications.tsx index 5c5ba16..cb79156 100644 --- a/ui/src/nav/notifications/Notifications.tsx +++ b/ui/src/nav/notifications/Notifications.tsx @@ -8,10 +8,9 @@ import Notification from './Notification'; import { useNotifications } from './useNotifications'; export const Notifications = ({ history }: RouteComponentProps) => { - const { notifications } = useNotifications(); + const { notifications, count } = useNotifications(); const { groups, retrieve } = groupStore(); - let timeout = 0 as unknown as NodeJS.Timeout; function visibilitychange() { if (document.visibilityState === 'visible') { @@ -22,13 +21,13 @@ export const Notifications = ({ history }: RouteComponentProps) => { clearTimeout(timeout); } } - + useEffect(() => { retrieve(); }, [retrieve]); useEffect(() => { - visibilitychange() + visibilitychange(); document.addEventListener('visibilitychange', visibilitychange); return () => { @@ -39,24 +38,31 @@ export const Notifications = ({ history }: RouteComponentProps) => { const markAllRead = useCallback(() => { useHarkState.getState().sawSeam({ all: null }); - }, []) + }, []); return ( history.push('/leap/notifications')} > -
-
-

All Notifications

- +
+
+

All Notifications

+ {count > 0 && ( + + )}
{notifications.map((grouping) => (
-

{grouping.date}

+

+ {grouping.date} +

    {grouping.bins.map((b) => (