FIX: If theres no valid file then dont attempt to scan for qr

This commit is contained in:
Marcos Rodriguez Velez 2025-01-02 20:58:04 -04:00
parent cbfc16e29b
commit 92c8bdc202

View File

@ -183,6 +183,9 @@ const CompanionDelegates = () => {
if (fileName && /\.(jpe?g|png)$/i.test(fileName)) {
try {
if (!decodedUrl) {
throw new Error(loc.send.qr_error_no_qrcode);
}
const values = await RNQRGenerator.detect({
uri: decodedUrl,
});
@ -200,11 +203,12 @@ const CompanionDelegates = () => {
},
);
} else {
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
presentAlert({ message: loc.send.qr_error_no_qrcode });
throw new Error(loc.send.qr_error_no_qrcode);
}
} catch (error) {
console.error('Error detecting QR code:', error);
triggerHapticFeedback(HapticFeedbackTypes.NotificationError);
presentAlert({ message: loc.send.qr_error_no_qrcode });
}
} else {
DeeplinkSchemaMatch.navigationRouteFor(event, (value: [string, any]) => navigationRef.navigate(...value), {