From 41cb6ac3d8c5a62e56399f1ee9fe814d77cdf65f Mon Sep 17 00:00:00 2001 From: keyan Date: Thu, 26 Oct 2023 11:53:00 -0500 Subject: [PATCH] continue notification polling even if found --- components/header.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/components/header.js b/components/header.js index 7083efe8..f92bb617 100644 --- a/components/header.js +++ b/components/header.js @@ -19,7 +19,7 @@ import LightningIcon from '../svgs/bolt.svg' import { Select } from './form' import SearchIcon from '../svgs/search-line.svg' import BackArrow from '../svgs/arrow-left-line.svg' -import { SUBS } from '../lib/constants' +import { SSR, SUBS } from '../lib/constants' import { useLightning } from './lightning' import { HAS_NOTIFICATIONS } from '../fragments/notifications' import AnonIcon from '../svgs/spy-fill.svg' @@ -52,19 +52,12 @@ function Back () { } function NotificationBell () { - const { data, startPolling, stopPolling } = useQuery(HAS_NOTIFICATIONS, { - nextFetchPolicy: 'cache-and-network' - }) - - // fine controlled polling - useEffect(() => { - if (data?.hasNewNotes) { - stopPolling() - } else { - startPolling(30000) - } - return stopPolling - }, [data?.hasNewNotes, startPolling, stopPolling]) + const { data } = useQuery(HAS_NOTIFICATIONS, SSR + ? {} + : { + pollInterval: 30000, + nextFetchPolicy: 'cache-and-network' + }) return ( <>