diff --git a/src/components/home.js b/src/components/home.js index d971efd..1821c61 100644 --- a/src/components/home.js +++ b/src/components/home.js @@ -42,7 +42,7 @@ export default function Home() { const [showLeftPanel, setShowLeftPanel] = useState(!isMobile); const [loginModalOpenNext, setLoginModalOpenNext] = useState(null); const isNewVisitor = useIsNewVisitor(); - const [displayExtensionBanner, closeExtensionBanner] = useDisplayExtensionBanner(); + const [displayExtensionBanner, closeExtensionBanner, checkForExtension] = useDisplayExtensionBanner(); const [isWelcomeModalOpen, setIsWelcomeModalOpen] = useState(true); const [newPreprints, setNewPreprints] = useNewPreprints(); @@ -120,6 +120,7 @@ export default function Home() { { setIsWelcomeModalOpen(false); + checkForExtension(); }} /> )} diff --git a/src/hooks/ui-hooks.js b/src/hooks/ui-hooks.js index f581dcc..98ad359 100644 --- a/src/hooks/ui-hooks.js +++ b/src/hooks/ui-hooks.js @@ -163,12 +163,16 @@ export function usePrevious(value) { export function useDisplayExtensionBanner() { const [displayExtensionBanner, setDisplayExtensionBanner] = useState(false); + const checkForExtension = () => { + setTimeout(() => { + const shouldDisplayExtensionBanner = localStorage.getItem('displayExtensionBanner') !== 'false' && !document.getElementById(CSS_SCOPE_ID); + setDisplayExtensionBanner(shouldDisplayExtensionBanner); + },500); + } + useEffect(() => { if(document.readyState === 'interactive' || document.readyState === 'complete'){ - setTimeout(() => { - const shouldDisplayExtensionBanner = localStorage.getItem('displayExtensionBanner') !== 'false' && !document.getElementById(CSS_SCOPE_ID); - setDisplayExtensionBanner(shouldDisplayExtensionBanner); - },500) + checkForExtension(); } }, []); @@ -177,5 +181,5 @@ export function useDisplayExtensionBanner() { setDisplayExtensionBanner(false); }, []); - return [displayExtensionBanner, localSet]; + return [displayExtensionBanner, localSet, checkForExtension]; } \ No newline at end of file