mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 08:23:35 +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 { 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 { Input } from '@/components/ui/input';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogDescription } from "@/components/ui/dialog";
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
generateNostrConnectURI,
|
||||
type NostrConnectParams,
|
||||
} from '@/hooks/useLoginActions';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface LoginDialogProps {
|
||||
@@ -53,6 +54,8 @@ const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onS
|
||||
const abortControllerRef = useRef<AbortController | null>(null);
|
||||
const login = useLoginActions();
|
||||
|
||||
// Check if on mobile device
|
||||
const isMobile = useIsMobile();
|
||||
// Check if extension is available
|
||||
const hasExtension = 'nostr' in window;
|
||||
|
||||
@@ -128,6 +131,13 @@ const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onS
|
||||
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 () => {
|
||||
setIsLoading(true);
|
||||
setErrors(prev => ({ ...prev, extension: undefined }));
|
||||
@@ -356,15 +366,17 @@ const LoginDialog: React.FC<LoginDialogProps> = ({ isOpen, onClose, onLogin, onS
|
||||
</div>
|
||||
) : nostrConnectUri ? (
|
||||
<>
|
||||
{/* QR Code */}
|
||||
<div className='p-4 bg-white rounded-xl'>
|
||||
<QRCodeSVG
|
||||
value={nostrConnectUri}
|
||||
size={180}
|
||||
level='M'
|
||||
includeMargin={false}
|
||||
/>
|
||||
</div>
|
||||
{/* QR Code - only show on desktop */}
|
||||
{!isMobile && (
|
||||
<div className='p-4 bg-white rounded-xl'>
|
||||
<QRCodeSVG
|
||||
value={nostrConnectUri}
|
||||
size={180}
|
||||
level='M'
|
||||
includeMargin={false}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Status message */}
|
||||
<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>Scan with your signer app</span>
|
||||
<span>{isMobile ? 'Open your signer app to connect' : 'Scan with your signer app'}</span>
|
||||
)}
|
||||
</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 */}
|
||||
<Button
|
||||
variant='outline'
|
||||
size='sm'
|
||||
className='gap-2'
|
||||
size={isMobile ? 'default' : 'sm'}
|
||||
className={isMobile ? 'w-full gap-2 rounded-full' : 'gap-2'}
|
||||
onClick={handleCopyUri}
|
||||
>
|
||||
{copied ? (
|
||||
|
||||
Reference in new issue
Block a user