diff --git a/src/views/profile/profile.tsx b/src/views/profile/profile.tsx index 771f1cbc..59702553 100644 --- a/src/views/profile/profile.tsx +++ b/src/views/profile/profile.tsx @@ -240,24 +240,24 @@ const Profile = () => { const { t } = useTranslation(); const account = useAccount(); const isMobile = useWindowWidth() < 640; - const [showInfobar, setShowInfobar] = useState(false); + // Show infobar for first 3 visits if account wasn't imported + const [showInfobar, setShowInfobar] = useState(() => { + const profileVisits = parseInt(localStorage.getItem('profileVisits') || '0'); + const importedAccountAddress = localStorage.getItem('importedAccountAddress'); + const shouldShow = profileVisits < 4 && importedAccountAddress !== account?.author?.address; + + if (shouldShow) { + localStorage.setItem('profileVisits', (profileVisits + 1).toString()); + } + + return shouldShow; + }); const profileTitle = account?.author?.displayName ? `${account?.author?.displayName} (u/${account?.author?.shortAddress})` : `u/${account?.author?.shortAddress}`; useEffect(() => { document.title = profileTitle + ' - Seedit'; }, [t, profileTitle]); - // Show infobar for first 3 visits if account wasn't imported - useEffect(() => { - const profileVisits = parseInt(localStorage.getItem('profileVisits') || '0'); - const importedAccountAddress = localStorage.getItem('importedAccountAddress'); - - if (profileVisits < 4 && importedAccountAddress !== account?.author?.address) { - setShowInfobar(true); - localStorage.setItem('profileVisits', (profileVisits + 1).toString()); - } - }, [account?.author?.address]); - const handleCloseInfobar = useCallback(() => { setShowInfobar(false); localStorage.setItem('profileVisits', '4');