@@ -227,4 +263,114 @@
);
}
-export default RestorationProgress;
+type AuthErrorProps = {
+ +error: mixed,
+ +handleRetry: () => void,
+};
+function AuthErrorView(props: AuthErrorProps): React.Node {
+ const { error, handleRetry } = props;
+
+ const rawErrorMessage = React.useMemo(
+ () => getMessageForException(error),
+ [error],
+ );
+
+ if (
+ rawErrorMessage === 'client_version_unsupported' ||
+ rawErrorMessage === 'unsupported_version'
+ ) {
+ return (
+
+ {getVersionUnsupportedError()}
+
+ );
+ } else if (rawErrorMessage === 'network_error') {
+ return (
+
+ Failed to contact Comm services. Please check your network connection.
+
+ );
+ } else {
+ return (
+
+ Uhh... try again?
+
+ );
+ }
+}
+
+type RestoreErrorProps = {
+ +error: Error,
+};
+function RestoreErrorView(props: RestoreErrorProps): React.Node {
+ const { error } = props;
+
+ if (error instanceof BackupIsNewerError) {
+ return (
+
+ {getBackupIsNewerThanAppError()}
+
+ );
+ } else {
+ return
;
+ }
+}
+
+export type RestorationViewProps = {
+ +qrAuthInProgress: boolean,
+ +userDataRestoreStarted: boolean,
+ +onErrorUIToggle?: (errorShown: boolean) => void,
+};
+function RestorationView(props: RestorationViewProps): React.Node {
+ const { qrAuthInProgress, userDataRestoreStarted, onErrorUIToggle } = props;
+
+ const { registerErrorListener } = useSecondaryDeviceQRAuthContext();
+ const [qrAuthError, setQRAuthError] = React.useState(null);
+ const userDataError = useSelector(state =>
+ state.restoreBackupState.status === 'user_data_restore_failed'
+ ? state.restoreBackupState.payload.error
+ : null,
+ );
+
+ React.useEffect(() => {
+ const subscription = registerErrorListener((error, isUserDataError) => {
+ if (isUserDataError) {
+ // user data errors are handled by selector
+ return;
+ }
+ setQRAuthError(error);
+ onErrorUIToggle?.(true);
+ });
+
+ return () => subscription.remove();
+ }, [registerErrorListener, onErrorUIToggle]);
+
+ const retryQRAuth = React.useCallback(() => {
+ setQRAuthError(null);
+ onErrorUIToggle?.(false);
+ }, [onErrorUIToggle]);
+
+ if (userDataError) {
+ return
;
+ } else if (qrAuthError) {
+ return
;
+ }
+
+ const step: RestorationStep =
+ qrAuthInProgress && !userDataRestoreStarted
+ ? 'authenticating'
+ : 'restoring';
+
+ return
;
+}
+
+export default RestorationView;
diff --git a/web/utils/qr-code-utils.js b/web/utils/qr-code-utils.js
--- a/web/utils/qr-code-utils.js
+++ b/web/utils/qr-code-utils.js
@@ -22,6 +22,7 @@
BackupIsNewerError,
getMessageForException,
} from 'lib/utils/errors.js';
+import { fullBackupSupport } from 'lib/utils/services-utils.js';
import { base64DecodeBuffer, base64EncodeBuffer } from './base64-utils.js';
import { getBackupIsNewerThanAppError } from './version-utils.js';
@@ -68,6 +69,11 @@
return React.useCallback(
(error: mixed, isUserDataRestoreError?: boolean) => {
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' ||