mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-16 08:08:56 -05:00
Fix modal not showing
This commit is contained in:
parent
8ff7080e84
commit
c7583b2ffe
@ -423,9 +423,21 @@ export function NeynarAuthButton() {
|
|||||||
if (message && signature) {
|
if (message && signature) {
|
||||||
const handleSignerFlow = async () => {
|
const handleSignerFlow = async () => {
|
||||||
try {
|
try {
|
||||||
|
const clientContext = context?.client as Record<string, unknown>;
|
||||||
|
const isMobileContext =
|
||||||
|
clientContext?.platformType === 'mobile' &&
|
||||||
|
clientContext?.clientFid === FARCASTER_FID;
|
||||||
|
|
||||||
|
// Step 1: Change to loading state
|
||||||
|
setDialogStep('loading');
|
||||||
|
|
||||||
|
// Show dialog if not using backend flow or in browser farcaster
|
||||||
|
if ((useBackendFlow && !isMobileContext) || !useBackendFlow)
|
||||||
|
setShowDialog(true);
|
||||||
|
|
||||||
// First, fetch existing signers
|
// First, fetch existing signers
|
||||||
const signers = await fetchAllSigners(message, signature);
|
const signers = await fetchAllSigners(message, signature);
|
||||||
setSignersLoading(true);
|
if (useBackendFlow && isMobileContext) setSignersLoading(true);
|
||||||
|
|
||||||
// Check if no signers exist or if we have empty signers
|
// Check if no signers exist or if we have empty signers
|
||||||
if (!signers || signers.length === 0) {
|
if (!signers || signers.length === 0) {
|
||||||
@ -439,13 +451,7 @@ export function NeynarAuthButton() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Step 3: Show QR code in access dialog for signer approval
|
// Step 3: Show QR code in access dialog for signer approval
|
||||||
if (signedKeyData.signer_approval_url) {
|
|
||||||
setSignerApprovalUrl(signedKeyData.signer_approval_url);
|
setSignerApprovalUrl(signedKeyData.signer_approval_url);
|
||||||
// Check if we're in a mobile context
|
|
||||||
const clientContext = context?.client as Record<string, unknown>;
|
|
||||||
const isMobileContext =
|
|
||||||
clientContext?.platformType === 'mobile' &&
|
|
||||||
clientContext?.clientFid === FARCASTER_FID;
|
|
||||||
|
|
||||||
if (isMobileContext) {
|
if (isMobileContext) {
|
||||||
setShowDialog(false);
|
setShowDialog(false);
|
||||||
@ -456,23 +462,25 @@ export function NeynarAuthButton() {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
setShowDialog(true); // Ensure dialog is shown during loading
|
||||||
setDialogStep('access');
|
setDialogStep('access');
|
||||||
setShowDialog(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4: Start polling for signer approval
|
// Step 4: Start polling for signer approval
|
||||||
startPolling(newSigner.signer_uuid, message, signature);
|
startPolling(newSigner.signer_uuid, message, signature);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
// If signers exist, close the dialog
|
||||||
setSignersLoading(false);
|
setSignersLoading(false);
|
||||||
setShowDialog(false);
|
setShowDialog(false);
|
||||||
setDialogStep('signin');
|
setDialogStep('signin');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Error in signer flow:', error);
|
console.error('❌ Error in signer flow:', error);
|
||||||
// On error, reset to signin step
|
// On error, reset to signin step and hide dialog
|
||||||
setDialogStep('signin');
|
setDialogStep('signin');
|
||||||
setSignersLoading(false);
|
setSignersLoading(false);
|
||||||
|
setShowDialog(false);
|
||||||
|
setSignerApprovalUrl(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -485,6 +493,8 @@ export function NeynarAuthButton() {
|
|||||||
createSigner,
|
createSigner,
|
||||||
generateSignedKeyRequest,
|
generateSignedKeyRequest,
|
||||||
startPolling,
|
startPolling,
|
||||||
|
context,
|
||||||
|
useBackendFlow,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Backend flow using NextAuth
|
// Backend flow using NextAuth
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user