Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32182171
D15171.1765078299.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D15171.1765078299.diff
View Options
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
@@ -15,6 +15,7 @@
import { useRestore, useV1Login } from './restore.js';
import { commCoreModule } from '../native-modules.js';
import { logInActionType } from '../navigation/action-types.js';
+import type { NavAction } from '../navigation/navigation-context.js';
import {
RestoreBackupErrorScreenRouteName,
type NavigationRoute,
@@ -36,7 +37,7 @@
+route: NavigationRoute<'RestoreBackupScreen'>,
};
-export type RestoreBackupScreenParams = {
+type PrimaryRestoreInfo = {
+userIdentifier: string,
+credentials:
| {
@@ -50,11 +51,16 @@
},
};
+export type RestoreBackupScreenParams = {
+ +primaryRestoreInfo?: PrimaryRestoreInfo,
+ +returnNavAction?: NavAction,
+};
+
function RestoreBackupScreen(props: Props): React.Node {
const styles = useStyles(unboundStyles);
const colors = useColors();
- const { userIdentifier, credentials } = props.route.params;
+ const { primaryRestoreInfo, returnNavAction } = props.route.params || {};
const restore = useRestore();
const performV1Login = useV1Login();
@@ -62,10 +68,13 @@
const isRestoreError = useSelector(
state => state.restoreBackupState.status === 'user_data_restore_failed',
);
- const canStartRestore = useSelector(
- state => state.restoreBackupState.status === 'no_backup',
+ const restoreHasStarted = useSelector(
+ state => state.restoreBackupState.status !== 'no_backup',
);
+ // Only start restoration if we have the necessary data
+ const shouldStartRestore = !!primaryRestoreInfo;
+
React.useEffect(() => {
const removeListener = props.navigation.addListener('beforeRemove', e => {
if (e.data.action.type !== logInActionType) {
@@ -81,10 +90,15 @@
});
return removeListener;
}
- if (!canStartRestore && fullBackupSupport) {
+ if ((restoreHasStarted || !shouldStartRestore) && fullBackupSupport) {
return removeListener;
}
void (async () => {
+ if (!primaryRestoreInfo) {
+ return;
+ }
+ const { userIdentifier, credentials } = primaryRestoreInfo;
+
let step;
const setStep = (newStep: string) => {
step = newStep;
@@ -163,14 +177,16 @@
errorTitle: alertDetails.title,
errorMessage: alertDetails.message,
rawErrorMessage: messageForException,
+ returnNavAction,
},
});
}
})();
return removeListener;
- // We want this effect to run exactly once
+ // We want this effect to run exactly once for the core logic, but it should
+ // update when shouldStartRestore changes
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
+ }, [shouldStartRestore]);
return (
<AuthContainer>
diff --git a/native/account/restore-password-account-screen.react.js b/native/account/restore-password-account-screen.react.js
--- a/native/account/restore-password-account-screen.react.js
+++ b/native/account/restore-password-account-screen.react.js
@@ -1,5 +1,6 @@
// @flow
+import { CommonActions } from '@react-navigation/native';
import * as React from 'react';
import { Text, TextInput, View } from 'react-native';
@@ -111,11 +112,14 @@
return;
}
props.navigation.navigate(RestoreBackupScreenRouteName, {
- userIdentifier: credentials.username,
- credentials: {
- type: 'password',
- password: credentials.password,
+ primaryRestoreInfo: {
+ userIdentifier: credentials.username,
+ credentials: {
+ type: 'password',
+ password: credentials.password,
+ },
},
+ returnNavAction: CommonActions.navigate({ key: props.route.key }),
});
} catch (e) {
const messageForException = getMessageForException(e);
@@ -156,6 +160,7 @@
onUnsuccessfulLoginAlertAcknowledged,
performV1Login,
props.navigation,
+ props.route.key,
retrieveLatestBackupInfo,
]);
diff --git a/native/backup/restore-siwe-backup.react.js b/native/backup/restore-siwe-backup.react.js
--- a/native/backup/restore-siwe-backup.react.js
+++ b/native/backup/restore-siwe-backup.react.js
@@ -1,5 +1,6 @@
// @flow
+import { CommonActions } from '@react-navigation/native';
import * as React from 'react';
import { type SIWEResult } from 'lib/types/siwe-types.js';
@@ -42,21 +43,24 @@
const onSuccessfulWalletSignature = React.useCallback(
(result: SIWEResult) => {
props.navigation.navigate(RestoreBackupScreenRouteName, {
- userIdentifier,
- credentials: {
- type: 'siwe',
- socialProof: {
- message,
- signature,
- },
- backup: {
- message: result.message,
- signature: result.signature,
+ primaryRestoreInfo: {
+ userIdentifier,
+ credentials: {
+ type: 'siwe',
+ socialProof: {
+ message,
+ signature,
+ },
+ backup: {
+ message: result.message,
+ signature: result.signature,
+ },
},
},
+ returnNavAction: CommonActions.navigate({ key: route.key }),
});
},
- [message, props.navigation, signature, userIdentifier],
+ [message, props.navigation, route.key, signature, userIdentifier],
);
return (
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 3:31 AM (13 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5841993
Default Alt Text
D15171.1765078299.diff (5 KB)
Attached To
Mode
D15171: [native] Conditionally start restore in RestoreBackupScreen
Attached
Detach File
Event Timeline
Log In to Comment