This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

refactor: only poll unread notif when authenticated

+3 -12
+3 -12
src/webapp/features/notifications/lib/queries/useUnreadNotificationCount.tsx
··· 2 2 import { getUnreadNotificationCount } from '../dal'; 3 3 import { notificationKeys } from '../notificationKeys'; 4 4 import { useAuth } from '@/hooks/useAuth'; 5 - import { ApiError } from '@/api-client'; 6 5 7 6 export default function useUnreadNotificationCount() { 8 - const { logout } = useAuth(); 7 + const { isAuthenticated } = useAuth(); 9 8 10 9 const query = useQuery({ 11 10 queryKey: notificationKeys.unreadCount(), 12 - queryFn: async () => { 13 - try { 14 - return await getUnreadNotificationCount(); 15 - } catch (error) { 16 - if (error instanceof ApiError && error.statusCode === 401) { 17 - logout(); 18 - } 19 - throw error; 20 - } 21 - }, 11 + queryFn: getUnreadNotificationCount, 12 + enabled: isAuthenticated, 22 13 staleTime: 3000, 23 14 refetchInterval: 20000, 24 15 refetchOnWindowFocus: true,