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
|
- **Desktop welcome sign-in modal (2026-10-26):** `Layout` opens the themed
|
||||||
`LoginDialog` **once** for a logged-out **desktop** visitor (non-native,
|
`LoginDialog` **once** for a logged-out **desktop** visitor (non-native,
|
||||||
`min-width: 1024px`, after ~900 ms) as a welcome/sign-in offer; dismissal is
|
`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,
|
normal `SignupDialog`. It reuses the existing methods (browser extension,
|
||||||
bunker/signer, Amber on Android, nsec, and the **NostrConnect QR**).
|
bunker/signer, Amber on Android, nsec, and the **NostrConnect QR**).
|
||||||
**3-card restyle (2026-10-26):** `LoginDialog` now leads with a **three-card
|
**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 { currentMessage, dismissCurrentMessage } = useSasquatchGuide();
|
||||||
const { user } = useCurrentUser();
|
const { user } = useCurrentUser();
|
||||||
|
|
||||||
// Desktop, logged-out, first visit: offer the sign-in modal once. Reuses the
|
// Desktop, logged-out welcome: shows once per browser session (not forever —
|
||||||
// themed LoginDialog/SignupDialog (extension, bunker/signer, Amber, nsec,
|
// a single ✕ used to suppress it permanently). `sessionStorage` survives a
|
||||||
// NostrConnect QR). Dismissal is remembered so it never nags again.
|
// reload but not a new tab/session, so "keep browsing" is respected without
|
||||||
const WELCOME_LOGIN_DISMISSED = 'skatespots:desktop-welcome-dismissed';
|
// killing the prompt for future visits.
|
||||||
|
const WELCOME_LOGIN_SNOOZED = 'skatespots:desktop-welcome-snoozed';
|
||||||
const [showWelcomeLogin, setShowWelcomeLogin] = useState(false);
|
const [showWelcomeLogin, setShowWelcomeLogin] = useState(false);
|
||||||
const [showWelcomeSignup, setShowWelcomeSignup] = useState(false);
|
const [showWelcomeSignup, setShowWelcomeSignup] = useState(false);
|
||||||
const dismissWelcomeLogin = () => {
|
const dismissWelcomeLogin = () => {
|
||||||
try { localStorage.setItem(WELCOME_LOGIN_DISMISSED, '1'); } catch { /* ignore */ }
|
try { sessionStorage.setItem(WELCOME_LOGIN_SNOOZED, '1'); } catch { /* ignore */ }
|
||||||
setShowWelcomeLogin(false);
|
setShowWelcomeLogin(false);
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user || isNativePlatform()) return;
|
if (user || isNativePlatform()) return;
|
||||||
try {
|
try {
|
||||||
if (localStorage.getItem(WELCOME_LOGIN_DISMISSED) === '1') return;
|
if (sessionStorage.getItem(WELCOME_LOGIN_SNOOZED) === '1') return;
|
||||||
} catch { return; }
|
} catch { return; }
|
||||||
if (typeof window === 'undefined' || !window.matchMedia?.('(min-width: 1024px)').matches) return;
|
if (typeof window === 'undefined' || !window.matchMedia?.('(min-width: 1024px)').matches) return;
|
||||||
const timer = window.setTimeout(() => setShowWelcomeLogin(true), 900);
|
const timer = window.setTimeout(() => setShowWelcomeLogin(true), 900);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue