mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
fix: add button on mobile web
This commit is contained in:
1 parent
ca1b0cd303
commit
2f6994f1e2
1 file changed
+36
-13
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { QRCodeSVG } from 'qrcode.react';
|
import { QRCodeSVG } from 'qrcode.react';
|
||||||
import { Shield, Upload, AlertTriangle, UserPlus, KeyRound, Sparkles, Loader2, Copy, Check, ChevronDown, ChevronUp, Link } from 'lucide-react';
|
import { Shield, Upload, AlertTriangle, UserPlus, KeyRound, Sparkles, Loader2, Copy, Check, ChevronDown, ChevronUp, Link, ExternalLink } from 'lucide-react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogDescription } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogHeader, DialogDescription } from "@/components/ui/dialog";
|
||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
generateNostrConnectURI,
|
generateNostrConnectURI,
|
||||||
type NostrConnectParams,
|
type NostrConnectParams,
|
||||||
} from '@/hooks/useLoginActions';
|
} from '@/hooks/useLoginActions';
|
||||||
|
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
|
||||||
interface LoginDialogProps {
|
interface LoginDialogProps {
|
||||||
@@ -53,6 +54,8 @@ const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onS
|
|||||||
const abortControllerRef = useRef<AbortController | null>(null);
|
const abortControllerRef = useRef<AbortController | null>(null);
|
||||||
const login = useLoginActions();
|
const login = useLoginActions();
|
||||||
|
|
||||||
|
// Check if on mobile device
|
||||||
|
const isMobile = useIsMobile();
|
||||||
// Check if extension is available
|
// Check if extension is available
|
||||||
const hasExtension = 'nostr' in window;
|
const hasExtension = 'nostr' in window;
|
||||||
|
|
||||||
@@ -128,6 +131,13 @@ const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onS
|
|||||||
setTimeout(() => setCopied(false), 2000);
|
setTimeout(() => setCopied(false), 2000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Open the nostrconnect URI in the system - this will launch a signer app like Amber if installed
|
||||||
|
const handleOpenSignerApp = () => {
|
||||||
|
if (!nostrConnectUri) return;
|
||||||
|
// On mobile, this will trigger the system to find an app that handles nostrconnect:// URIs
|
||||||
|
window.location.href = nostrConnectUri;
|
||||||
|
};
|
||||||
|
|
||||||
const handleExtensionLogin = async () => {
|
const handleExtensionLogin = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setErrors(prev => ({ ...prev, extension: undefined }));
|
setErrors(prev => ({ ...prev, extension: undefined }));
|
||||||
@@ -356,15 +366,17 @@ const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onS
|
|||||||
</div>
|
</div>
|
||||||
) : nostrConnectUri ? (
|
) : nostrConnectUri ? (
|
||||||
<>
|
<>
|
||||||
{/* QR Code */}
|
{/* QR Code - only show on desktop */}
|
||||||
<div className='p-4 bg-white rounded-xl'>
|
{!isMobile && (
|
||||||
<QRCodeSVG
|
<div className='p-4 bg-white rounded-xl'>
|
||||||
value={nostrConnectUri}
|
<QRCodeSVG
|
||||||
size={180}
|
value={nostrConnectUri}
|
||||||
level='M'
|
size={180}
|
||||||
includeMargin={false}
|
level='M'
|
||||||
/>
|
includeMargin={false}
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Status message */}
|
{/* Status message */}
|
||||||
<div className='flex items-center gap-2 text-sm text-muted-foreground'>
|
<div className='flex items-center gap-2 text-sm text-muted-foreground'>
|
||||||
@@ -374,15 +386,26 @@ const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onS
|
|||||||
<span>Waiting for connection...</span>
|
<span>Waiting for connection...</span>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<span>Scan with your signer app</span>
|
<span>{isMobile ? 'Open your signer app to connect' : 'Scan with your signer app'}</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Open Signer App button - primary action on mobile */}
|
||||||
|
{isMobile && (
|
||||||
|
<Button
|
||||||
|
className='w-full gap-2 py-6 rounded-full'
|
||||||
|
onClick={handleOpenSignerApp}
|
||||||
|
>
|
||||||
|
<ExternalLink className='w-5 h-5' />
|
||||||
|
Open Signer App
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Copy button */}
|
{/* Copy button */}
|
||||||
<Button
|
<Button
|
||||||
variant='outline'
|
variant='outline'
|
||||||
size='sm'
|
size={isMobile ? 'default' : 'sm'}
|
||||||
className='gap-2'
|
className={isMobile ? 'w-full gap-2 rounded-full' : 'gap-2'}
|
||||||
onClick={handleCopyUri}
|
onClick={handleCopyUri}
|
||||||
>
|
>
|
||||||
{copied ? (
|
{copied ? (
|
||||||
|
|||||||
Reference in new issue
Block a user