From d861bed8268ed495c4d88abf8a7a457fe7b7e6a0 Mon Sep 17 00:00:00 2001 From: "Seshanth.S" <35675963+seshanthS@users.noreply.github.com> Date: Tue, 14 Apr 2026 00:46:09 +0530 Subject: [PATCH] Fix navigation in disclose result related screens (#1964) * Fix navigation in disclose result related screens * coderabbit comments --- .../tunnel/TunnelProofReceiptScreen.tsx | 9 ----- .../src/screens/tunnel/TunnelResultScreen.tsx | 36 +++++++++++-------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/packages/webview-app/src/screens/tunnel/TunnelProofReceiptScreen.tsx b/packages/webview-app/src/screens/tunnel/TunnelProofReceiptScreen.tsx index cf7a55567..e5398a1fc 100644 --- a/packages/webview-app/src/screens/tunnel/TunnelProofReceiptScreen.tsx +++ b/packages/webview-app/src/screens/tunnel/TunnelProofReceiptScreen.tsx @@ -21,14 +21,6 @@ export const TunnelProofReceiptScreen: React.FC = () => { const { backPath = '/tunnel/proof/result', backState } = (location.state as { backPath?: string; backState?: Record } | null) ?? {}; - const showConfirm = backPath !== '/tunnel/proof/result' || backState?.success === true; - - const onConfirm = useCallback(() => { - haptic.trigger('selection'); - analytics.trackEvent('tunnel_proof_receipt_confirmed'); - navigate('/tunnel/proof/disclose'); - }, [navigate, haptic, analytics]); - const proofItems = useMemo(() => { if (displayLabels && displayLabels.length > 0) { return displayLabels.map(label => ({ label })); @@ -49,7 +41,6 @@ export const TunnelProofReceiptScreen: React.FC = () => { {...WEB_SAFE_AREA} variant="default" onClose={onClose} - onConfirm={showConfirm ? onConfirm : undefined} appIcon={} appName={appName} appEndpoint={appEndpoint} diff --git a/packages/webview-app/src/screens/tunnel/TunnelResultScreen.tsx b/packages/webview-app/src/screens/tunnel/TunnelResultScreen.tsx index b563a6f00..3db6a4e73 100644 --- a/packages/webview-app/src/screens/tunnel/TunnelResultScreen.tsx +++ b/packages/webview-app/src/screens/tunnel/TunnelResultScreen.tsx @@ -31,18 +31,6 @@ const getTunnelBackPath = (source: TunnelResultState['source']): string => { } }; -const getTunnelClosePath = (source: TunnelResultState['source']): string => { - switch (source) { - case 'disclose': - return '/tunnel/proof/disclose'; - case 'kyc': - return '/tunnel/kyc'; - case 'proving': - default: - return '/tunnel/tour/4'; - } -}; - export const TunnelResultScreen: React.FC = () => { const navigate = useNavigate(); const location = useLocation(); @@ -84,9 +72,27 @@ export const TunnelResultScreen: React.FC = () => { }); }, [location.pathname, location.state, navigate]); - const onCancel = useCallback(() => { - navigate(getTunnelClosePath(source), { replace: true }); - }, [navigate, source]); + const onCancel = useCallback(async () => { + try { + const result: VerificationResult = { + success: false, + userId: request.userId, + verificationId, + error: { + code: 'VERIFICATION_FAILED', + message: error ?? 'Verification failed', + }, + }; + await lifecycle.setResult(result); + analytics.trackEvent('tunnel_result_cancelled', { source }); + lifecycle.dismiss(); + } catch (err) { + analytics.trackEvent('tunnel_result_cancel_failed', { + error: err instanceof Error ? err.message : 'Failed to send cancel result', + }); + lifecycle.dismiss(); + } + }, [request.userId, verificationId, error, lifecycle, analytics, source]); if (success) { return (