@@ -7,10 +7,11 @@ import {
77 ExclamationTriangleIcon ,
88 ShieldExclamationIcon ,
99} from " @heroicons/vue/24/solid" ;
10- import { cn } from " ../shadcn/utils" ;
10+ import { cn } from ' ~/components/shadcn/utils'
11+ import { onWatcherCleanup } from " vue" ;
1112
1213const { result } = useQuery (unreadOverview , null , {
13- pollInterval: 1_000 , // 1 second
14+ pollInterval: 2_000 , // 2 seconds
1415});
1516
1617const overview = computed (() => {
@@ -51,6 +52,22 @@ const icon = computed<{ component: Component; color: string } | null>(() => {
5152 }
5253 return null ;
5354});
55+
56+ /** whether new notifications ocurred */
57+ const hasNewNotifications = ref (false );
58+ // watch for new notifications, set a temporary indicator when they're reveived
59+ watch (overview , (newVal , oldVal ) => {
60+ if (! newVal || ! oldVal ) {
61+ return ;
62+ }
63+ hasNewNotifications .value = newVal .total > oldVal .total ;
64+ // lifetime of 'new notification' state
65+ const msToLive = 30_000 ;
66+ const timeout = setTimeout (() => {
67+ hasNewNotifications .value = false ;
68+ }, msToLive );
69+ onWatcherCleanup (() => clearTimeout (timeout ));
70+ });
5471 </script >
5572
5673<template >
@@ -68,7 +85,7 @@ const icon = computed<{ component: Component; color: string } | null>(() => {
6885 "
6986 />
7087 <div
71- v-if =" indicatorLevel === Importance.Alert"
88+ v-if =" hasNewNotifications || indicatorLevel === Importance.Alert"
7289 class =" absolute top-0 right-0 size-2.5 rounded-full bg-unraid-red animate-ping"
7390 />
7491 </div >
0 commit comments