Merge pull request #7568 from BlueWallet/Nav

FIX: Dont run checks in ScanQrcode
This commit is contained in:
GLaDOS 2025-02-07 11:37:29 +00:00 committed by GitHub
commit d2e186bbf7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,7 +7,12 @@ import { requestCameraAuthorization } from '../helpers/scan-qr';
import { useCallback, useMemo } from 'react';
// List of screens that require biometrics
const requiresBiometrics = ['WalletExportRoot', 'WalletXpubRoot', 'ViewEditMultisigCosignersRoot', 'ExportMultisigCoordinationSetupRoot'];
const requiresBiometrics = [
'WalletExportRoot',
'WalletXpubRoot',
'ViewEditMultisigCosignersRoot',
'ExportMultisigCoordinationSetupRoot',
];
// List of screens that require wallet export to be saved
const requiresWalletExportIsSaved = ['ReceiveDetailsRoot', 'WalletAddresses'];
@ -44,6 +49,13 @@ export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>()
};
(async () => {
// NEW: If the current (active) screen is 'ScanQRCode', bypass all checks.
const currentRouteName = navigationRef.current?.getCurrentRoute()?.name;
if (currentRouteName === 'ScanQRCode') {
proceedWithNavigation();
return;
}
if (isRequiresBiometrics) {
const isBiometricsEnabled = await isBiometricUseEnabled();
if (isBiometricsEnabled) {
@ -53,8 +65,8 @@ export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>()
return;
} else {
console.error('Biometric authentication failed');
// Decide if navigation should proceed or not after failed authentication
return; // Prevent proceeding with the original navigation if bio fails
// Do not proceed if authentication fails.
return;
}
}
}
@ -78,18 +90,17 @@ export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>()
await saveToDisk();
proceedWithNavigation();
} catch (error) {
if (error) {
originalNavigation.navigate('WalletExportRoot', {
screen: 'WalletExport',
params: { walletID },
});
}
// If there was an error (or the user cancelled), navigate to the wallet export screen.
originalNavigation.navigate('WalletExportRoot', {
screen: 'WalletExport',
params: { walletID },
});
}
return; // Prevent proceeding with the original navigation if the reminder is shown
return; // Do not proceed with the original navigation if reminder was shown.
}
}
// If the target screen is ScanQRCode, request camera authorization.
if (screenName === 'ScanQRCode') {
await requestCameraAuthorization();
}
@ -115,4 +126,4 @@ export const useExtendedNavigation = <T extends NavigationProp<ParamListBase>>()
// Usage example:
// type NavigationProps = NativeStackNavigationProp<SendDetailsStackParamList, 'SendDetails'>;
// const navigation = useExtendedNavigation<NavigationProps>();
// const navigation = useExtendedNavigation<NavigationProps>();