mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-03 08:07:21 +00:00
fix: callback enhancements
This commit is contained in:
1 parent
ac88a3a5c1
commit
8a4f97beba
1 file changed
+12
-5
@@ -3,8 +3,8 @@ import { useNavigate } from 'react-router-dom';
|
||||
import { useNostrLogin } from '@nostrify/react/login';
|
||||
import { Loader2, CheckCircle, XCircle } from 'lucide-react';
|
||||
|
||||
// Storage key used by @nostrify/react for logins
|
||||
const LOGINS_STORAGE_KEY = 'nostrify:logins';
|
||||
// Storage key must match the one in App.tsx NostrLoginProvider
|
||||
const LOGINS_STORAGE_KEY = 'nostr:login';
|
||||
|
||||
export function RemoteLoginSuccess() {
|
||||
const navigate = useNavigate();
|
||||
@@ -33,7 +33,11 @@ export function RemoteLoginSuccess() {
|
||||
if (isLoggedIn) {
|
||||
setStatus('success');
|
||||
const timer = setTimeout(() => {
|
||||
navigate('/', { replace: true });
|
||||
// Try to close this tab (works if opened by signer app)
|
||||
// This leaves the user on the original tab which should detect the login
|
||||
window.close();
|
||||
// If we're still here (close didn't work), do a full page redirect
|
||||
window.location.href = '/';
|
||||
}, 1500);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
@@ -57,7 +61,10 @@ export function RemoteLoginSuccess() {
|
||||
const parsed = JSON.parse(e.newValue);
|
||||
if (Array.isArray(parsed) && parsed.length > 0) {
|
||||
setStatus('success');
|
||||
setTimeout(() => navigate('/', { replace: true }), 1500);
|
||||
setTimeout(() => {
|
||||
window.close();
|
||||
window.location.href = '/';
|
||||
}, 1500);
|
||||
}
|
||||
} catch {
|
||||
// Ignore parse errors
|
||||
@@ -67,7 +74,7 @@ export function RemoteLoginSuccess() {
|
||||
|
||||
window.addEventListener('storage', handleStorage);
|
||||
return () => window.removeEventListener('storage', handleStorage);
|
||||
}, [navigate]);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center bg-background">
|
||||
|
||||
Reference in new issue
Block a user