Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client

[APP-1761] Prevent welcome modal from reappearing (#9786)

* store welcome modal appearance in localstorage

* lint

* redundancy

authored by

Spence Pope and committed by
GitHub
b9c92d39 d45a2c83

+7 -11
+7 -11
src/components/hooks/useWelcomeModal.ts
··· 8 8 const [isOpen, setIsOpen] = useState(false) 9 9 10 10 const open = () => setIsOpen(true) 11 - const close = () => { 12 - setIsOpen(false) 13 - // Mark that user has actively closed the modal, don't show again this session 14 - if (typeof window !== 'undefined') { 15 - sessionStorage.setItem('welcomeModalClosed', 'true') 16 - } 17 - } 11 + const close = () => setIsOpen(false) 18 12 19 13 useEffect(() => { 20 14 // Only show modal if: 21 15 // 1. User is not logged in 22 16 // 2. We're on the web (this is a web-only feature) 23 17 // 3. We're on the homepage (path is '/' or '/home') 24 - // 4. User hasn't actively closed the modal in this session 18 + // 4. Modal hasn't been shown before 25 19 if (IS_WEB && !hasSession && typeof window !== 'undefined') { 26 20 const currentPath = window.location.pathname 27 21 const isHomePage = currentPath === '/' 28 - const hasUserClosedModal = 29 - sessionStorage.getItem('welcomeModalClosed') === 'true' 22 + const hasModalBeenShown = 23 + localStorage.getItem('welcomeModalShown') === 'true' 30 24 31 - if (isHomePage && !hasUserClosedModal) { 25 + if (isHomePage && !hasModalBeenShown) { 26 + // Mark that the modal has been shown, don't show again 27 + localStorage.setItem('welcomeModalShown', 'true') 32 28 // Small delay to ensure the page has loaded 33 29 const timer = setTimeout(() => { 34 30 open()