isLoggedIn = NostrAuth::check(); if (! $this->isLoggedIn) { // Sidebar + navbar mount the same component on the same page; using // currentOrIssueChallenge keeps both rendered data-attributes // pointing at the same live session value. $this->nostrChallenge = NostrAuth::currentOrIssueChallenge(); } } /** * JS-driven fallback: re-issue the challenge if the client cannot find * one in the rendered snapshot (e.g. after a long-lived tab where the * Volt component snapshot drifted out of sync with the session). */ public function requestNostrChallenge(): string { $challenge = NostrAuth::issueChallenge(); $this->nostrChallenge = $challenge; return $challenge; } #[On('nostrLoggedIn')] public function handleNostrLoggedIn($signedEvent = null): void { NostrAuth::loginWithSignedEvent($signedEvent); $this->js('window.location.reload(true);'); } #[On('nostrLoggedOut')] public function handleNostrLoggedOut(): void { $this->isLoggedIn = false; } } ?>