Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33110246
D14533.1768480733.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D14533.1768480733.diff
View Options
diff --git a/native/account/restore.js b/native/account/restore.js
--- a/native/account/restore.js
+++ b/native/account/restore.js
@@ -4,10 +4,12 @@
import * as React from 'react';
import { Platform } from 'react-native';
+import { setClientDBStoreActionType } from 'lib/actions/client-db-store-actions.js';
import {
restoreUserActionTypes,
type RestoreUserResult,
} from 'lib/actions/user-actions.js';
+import { useDebugLogs } from 'lib/components/debug-logs-context.js';
import {
useLogIn,
usePasswordLogIn,
@@ -25,7 +27,8 @@
import { composeRawDeviceList } from 'lib/utils/device-list-utils.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
-import { useSelector } from 'lib/utils/redux-utils.js';
+import { useDispatch, useSelector } from 'lib/utils/redux-utils.js';
+import { fullBackupSupport } from 'lib/utils/services-utils.js';
import { setNativeCredentials } from './native-credentials.js';
import { useClientBackup } from '../backup/use-client-backup.js';
@@ -175,11 +178,52 @@
[dispatchActionPromise, restoreProtocol],
);
+ const dispatch = useDispatch();
+ const { addLog } = useDebugLogs();
+ const restoreUserData = React.useCallback(
+ async (identityAuthResult: ?IdentityAuthResult) => {
+ if (!fullBackupSupport) {
+ return;
+ }
+ try {
+ const { sqliteAPI } = getConfig();
+ if (!identityAuthResult) {
+ throw new Error('Missing identityAuthResult');
+ }
+ const backupData = await commCoreModule.getQRAuthBackupData();
+ await sqliteAPI.restoreUserData(backupData, identityAuthResult);
+
+ const clientDBStore = await sqliteAPI.getClientDBStore(
+ identityAuthResult.userID,
+ );
+ dispatch({
+ type: setClientDBStoreActionType,
+ payload: clientDBStore,
+ });
+ } catch (e) {
+ addLog(
+ 'Error when restoring User Data',
+ getMessageForException(e) ?? 'unknown error',
+ );
+ }
+ },
+ [addLog, dispatch],
+ );
+
const logIn = useLogIn('restore');
return React.useCallback(
- (userIdentifier: string, secret: string, siweSocialProof?: SignedMessage) =>
- logIn(restoreAuth(userIdentifier, secret, siweSocialProof)),
- [logIn, restoreAuth],
+ async (
+ userIdentifier: string,
+ secret: string,
+ siweSocialProof?: SignedMessage,
+ ) => {
+ const identityAuthResult = await logIn(
+ restoreAuth(userIdentifier, secret, siweSocialProof),
+ );
+ await restoreUserData(identityAuthResult);
+ return identityAuthResult;
+ },
+ [logIn, restoreAuth, restoreUserData],
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 15, 12:38 PM (11 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5937999
Default Alt Text
D14533.1768480733.diff (2 KB)
Attached To
Mode
D14533: [lib] attempt restoring User Data after restoring primary device
Attached
Detach File
Event Timeline
Log In to Comment