Page MenuHomePhorge

D15170.1765044688.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D15170.1765044688.diff

diff --git a/native/account/qr-auth-progress-screen.react.js b/native/account/qr-auth-progress-screen.react.js
--- a/native/account/qr-auth-progress-screen.react.js
+++ b/native/account/qr-auth-progress-screen.react.js
@@ -1,21 +1,28 @@
// @flow
-import { useFocusEffect } from '@react-navigation/core';
+import { CommonActions, useFocusEffect } from '@react-navigation/core';
import * as React from 'react';
import { View, Text } from 'react-native';
import * as Progress from 'react-native-progress';
import { useSecondaryDeviceQRAuthContext } from 'lib/components/secondary-device-qr-auth-context-provider.react.js';
+import { getMessageForException } from 'lib/utils/errors.js';
import AuthContainer from './auth-components/auth-container.react.js';
import AuthContentContainer from './auth-components/auth-content-container.react.js';
import type { AuthNavigationProp } from './registration/auth-navigator.react.js';
import {
RestoreBackupErrorScreenRouteName,
+ QRCodeScreenRouteName,
type NavigationRoute,
} from '../navigation/route-names.js';
import { useSelector } from '../redux/redux-utils.js';
import { useColors, useStyles } from '../themes/colors.js';
+import {
+ appOutOfDateAlertDetails,
+ networkErrorAlertDetails,
+ unknownErrorAlertDetails,
+} from '../utils/alert-messages.js';
type ProgressStepProps = {
+stepNumber: string,
@@ -61,7 +68,8 @@
const styles = useStyles(unboundStyles);
const colors = useColors();
- const { qrAuthInProgress } = useSecondaryDeviceQRAuthContext();
+ const { qrAuthInProgress, registerErrorListener } =
+ useSecondaryDeviceQRAuthContext();
const userDataRestoreStatus = useSelector(
state => state.restoreBackupState.status,
);
@@ -79,6 +87,44 @@
}, [props.navigation, userDataRestoreStatus]),
);
+ useFocusEffect(
+ React.useCallback(() => {
+ if (!registerErrorListener) {
+ return undefined;
+ }
+ const subscription = registerErrorListener((error, isUserDataError) => {
+ if (isUserDataError) {
+ // user data errors are handled by selector
+ return;
+ }
+
+ const messageForException = getMessageForException(error);
+ let alertDetails = unknownErrorAlertDetails;
+ if (
+ messageForException === 'client_version_unsupported' ||
+ messageForException === 'unsupported_version'
+ ) {
+ alertDetails = appOutOfDateAlertDetails;
+ } else if (messageForException === 'network_error') {
+ alertDetails = networkErrorAlertDetails;
+ }
+ props.navigation.navigate(RestoreBackupErrorScreenRouteName, {
+ errorInfo: {
+ type: 'generic_error',
+ errorTitle: alertDetails.title,
+ errorMessage: alertDetails.message,
+ rawErrorMessage: messageForException,
+ returnNavAction: CommonActions.navigate({
+ name: QRCodeScreenRouteName,
+ }),
+ },
+ });
+ });
+
+ return () => subscription.remove();
+ }, [registerErrorListener, props.navigation]),
+ );
+
const userDataRestoreStarted = userDataRestoreStatus !== 'no_backup';
const step: 'authenticating' | 'restoring' =
qrAuthInProgress && !userDataRestoreStarted
diff --git a/native/account/restore-backup-screen.react.js b/native/account/restore-backup-screen.react.js
--- a/native/account/restore-backup-screen.react.js
+++ b/native/account/restore-backup-screen.react.js
@@ -30,7 +30,6 @@
siweLoginErrorAlertDetails,
userKeysRestoreErrorAlertDetails,
} from '../utils/alert-messages.js';
-import Alert from '../utils/alert.js';
type Props = {
+navigation: AuthNavigationProp<'RestoreBackupScreen'>,
@@ -112,7 +111,6 @@
);
}
} catch (e) {
- removeListener();
const messageForException = getMessageForException(e);
console.log(
`Backup restore error: ${messageForException ?? 'unknown error'}`,
@@ -157,12 +155,16 @@
});
return;
}
- Alert.alert(
- alertDetails.title,
- alertDetails.message,
- [{ text: 'OK', onPress: props.navigation.goBack }],
- { cancelable: false },
- );
+
+ removeListener();
+ props.navigation.navigate(RestoreBackupErrorScreenRouteName, {
+ errorInfo: {
+ type: 'generic_error',
+ errorTitle: alertDetails.title,
+ errorMessage: alertDetails.message,
+ rawErrorMessage: messageForException,
+ },
+ });
}
})();
return removeListener;
diff --git a/native/utils/qr-code-utils.js b/native/utils/qr-code-utils.js
--- a/native/utils/qr-code-utils.js
+++ b/native/utils/qr-code-utils.js
@@ -13,6 +13,7 @@
BackupIsNewerError,
getMessageForException,
} from 'lib/utils/errors.js';
+import { fullBackupSupport } from 'lib/utils/services-utils.js';
import * as AES from './aes-crypto-module.js';
import {
@@ -65,6 +66,10 @@
function handleSecondaryDeviceLogInError(error: mixed): void {
console.error('Secondary device log in error:', error);
+ if (fullBackupSupport) {
+ // for full backup, errors are handled in the restore UI
+ return;
+ }
const messageForException = getMessageForException(error);
if (
messageForException === 'client_version_unsupported' ||

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 6, 6:11 PM (3 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5840035
Default Alt Text
D15170.1765044688.diff (5 KB)

Event Timeline