fix(auth): show the desktop welcome sign-in once per session
The dismissal was stored in localStorage, so one early ✕ suppressed the prompt forever. Switch to sessionStorage (key skatespots:desktop-welcome-snoozed): it reappears in a new tab/session but respects 'keep browsing' for the current one.
This commit is contained in:
parent
fe3d9bae22
commit
8badbeacf1
2 changed files with 10 additions and 7 deletions
|
|
@ -1525,7 +1525,9 @@ session with **no other memory of this project**. So:
|
|||
- **Desktop welcome sign-in modal (2026-10-26):** `Layout` opens the themed
|
||||
`LoginDialog` **once** for a logged-out **desktop** visitor (non-native,
|
||||
`min-width: 1024px`, after ~900 ms) as a welcome/sign-in offer; dismissal is
|
||||
remembered in `skatespots:desktop-welcome-dismissed`, and it also offers the
|
||||
remembered in `sessionStorage['skatespots:desktop-welcome-snoozed']` (per
|
||||
session, not forever — a single ✕ must not suppress it permanently), and it
|
||||
also offers the
|
||||
normal `SignupDialog`. It reuses the existing methods (browser extension,
|
||||
bunker/signer, Amber on Android, nsec, and the **NostrConnect QR**).
|
||||
**3-card restyle (2026-10-26):** `LoginDialog` now leads with a **three-card
|
||||
|
|
|
|||
|
|
@ -518,20 +518,21 @@ export function Layout({ children, noPadding }: LayoutProps) {
|
|||
const { currentMessage, dismissCurrentMessage } = useSasquatchGuide();
|
||||
const { user } = useCurrentUser();
|
||||
|
||||
// Desktop, logged-out, first visit: offer the sign-in modal once. Reuses the
|
||||
// themed LoginDialog/SignupDialog (extension, bunker/signer, Amber, nsec,
|
||||
// NostrConnect QR). Dismissal is remembered so it never nags again.
|
||||
const WELCOME_LOGIN_DISMISSED = 'skatespots:desktop-welcome-dismissed';
|
||||
// Desktop, logged-out welcome: shows once per browser session (not forever —
|
||||
// a single ✕ used to suppress it permanently). `sessionStorage` survives a
|
||||
// reload but not a new tab/session, so "keep browsing" is respected without
|
||||
// killing the prompt for future visits.
|
||||
const WELCOME_LOGIN_SNOOZED = 'skatespots:desktop-welcome-snoozed';
|
||||
const [showWelcomeLogin, setShowWelcomeLogin] = useState(false);
|
||||
const [showWelcomeSignup, setShowWelcomeSignup] = useState(false);
|
||||
const dismissWelcomeLogin = () => {
|
||||
try { localStorage.setItem(WELCOME_LOGIN_DISMISSED, '1'); } catch { /* ignore */ }
|
||||
try { sessionStorage.setItem(WELCOME_LOGIN_SNOOZED, '1'); } catch { /* ignore */ }
|
||||
setShowWelcomeLogin(false);
|
||||
};
|
||||
useEffect(() => {
|
||||
if (user || isNativePlatform()) return;
|
||||
try {
|
||||
if (localStorage.getItem(WELCOME_LOGIN_DISMISSED) === '1') return;
|
||||
if (sessionStorage.getItem(WELCOME_LOGIN_SNOOZED) === '1') return;
|
||||
} catch { return; }
|
||||
if (typeof window === 'undefined' || !window.matchMedia?.('(min-width: 1024px)').matches) return;
|
||||
const timer = window.setTimeout(() => setShowWelcomeLogin(true), 900);
|
||||
|
|
|
|||
Loading…
Reference in a new issue