Merge pull request #1485 from blockscout/fix-wallet-tooltip

Fix wallet tooltip
This commit is contained in:
tom goriunov
2024-01-16 16:42:39 +04:00
committed by GitHub
+10 -5
View File
@@ -2,6 +2,8 @@ import { Tooltip, useBoolean, useOutsideClick } from '@chakra-ui/react';
import { useRouter } from 'next/router';
import React from 'react';
import { SECOND } from 'lib/consts';
type Props = {
children: React.ReactNode;
isDisabled?: boolean;
@@ -26,12 +28,15 @@ const WalletTooltip = ({ children, isDisabled, isMobile }: Props) => {
React.useEffect(() => {
const wasShown = window.localStorage.getItem(localStorageKey);
if (!isDisabled && !wasShown) {
setIsTooltipShown.on();
window.localStorage.setItem(localStorageKey, 'true');
setTimeout(() => setIsTooltipShown.off(), 3000);
const isMarketplacePage = [ '/apps', '/apps/[id]' ].includes(router.pathname);
if (!isDisabled && !wasShown && isMarketplacePage) {
setTimeout(() => {
setIsTooltipShown.on();
window.localStorage.setItem(localStorageKey, 'true');
setTimeout(() => setIsTooltipShown.off(), 5 * SECOND);
}, SECOND);
}
}, [ setIsTooltipShown, localStorageKey, isDisabled ]);
}, [ setIsTooltipShown, localStorageKey, isDisabled, router.pathname ]);
return (
<Tooltip