Bluesky app fork with some witchin' additions 馃挮
witchsky.app
bluesky
fork
client
1import {useEffect, useState} from 'react'
2
3import {useSession} from '#/state/session'
4import {IS_WEB} from '#/env'
5
6export function useWelcomeModal() {
7 const {hasSession} = useSession()
8 const [isOpen, setIsOpen] = useState(false)
9
10 const open = () => setIsOpen(true)
11 const close = () => setIsOpen(false)
12
13 useEffect(() => {
14 // Only show modal if:
15 // 1. User is not logged in
16 // 2. We're on the web (this is a web-only feature)
17 // 3. We're on the homepage (path is '/' or '/home')
18 // 4. Modal hasn't been shown before
19 if (IS_WEB && !hasSession && typeof window !== 'undefined') {
20 const currentPath = window.location.pathname
21 const isHomePage = currentPath === '/'
22 const hasModalBeenShown =
23 localStorage.getItem('welcomeModalShown') === 'true'
24
25 if (isHomePage && !hasModalBeenShown) {
26 // Mark that the modal has been shown, don't show again
27 localStorage.setItem('welcomeModalShown', 'true')
28 // Small delay to ensure the page has loaded
29 const timer = setTimeout(() => {
30 open()
31 }, 1000)
32
33 return () => clearTimeout(timer)
34 }
35 }
36 }, [hasSession])
37
38 return {isOpen, open, close}
39}