From 9c5937b9be7aa570e0d47c0138ee1326634b470b Mon Sep 17 00:00:00 2001 From: keyan Date: Wed, 26 Oct 2022 11:45:16 -0500 Subject: [PATCH] strike once for lurkers --- components/header.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/header.js b/components/header.js index fb49b551..1580dcfb 100644 --- a/components/header.js +++ b/components/header.js @@ -122,9 +122,18 @@ export default function Header ({ sub }) { if (!fired) { const strike = useLightning() useEffect(() => { - setTimeout(strike, randInRange(3000, 10000)) - setFired(true) - }, [router.asPath]) + let isMounted = true + if (!localStorage.getItem('striked')) { + setTimeout(() => { + if (isMounted) { + strike() + localStorage.setItem('striked', 'yep') + setFired(true) + } + }, randInRange(3000, 10000)) + } + return () => { isMounted = false } + }, []) } return path !== '/login' && !path.startsWith('/invites') &&