Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3332687
D13935.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13935.diff
View Options
diff --git a/native/backup/use-client-backup.js b/native/backup/use-client-backup.js
--- a/native/backup/use-client-backup.js
+++ b/native/backup/use-client-backup.js
@@ -16,6 +16,7 @@
type ClientBackup = {
+uploadBackupProtocol: () => Promise<void>,
+ +createUserKeysBackup: () => Promise<void>,
+retrieveLatestBackupInfo: () => Promise<LatestBackupInfo>,
};
@@ -51,6 +52,15 @@
console.info('Backup uploaded.');
}, [loggedIn, currentUserID, currentUserInfo, getBackupSecret]);
+ const createUserKeysBackup = React.useCallback(async () => {
+ if (!loggedIn || !currentUserID) {
+ throw new Error('Attempt to upload User Keys for not logged in user.');
+ }
+
+ const backupSecret = await getBackupSecret();
+ await commCoreModule.createUserKeysBackup(backupSecret);
+ }, [loggedIn, currentUserID, getBackupSecret]);
+
const retrieveLatestBackupInfo = React.useCallback(async () => {
if (!loggedIn || !currentUserID || !currentUserInfo?.username) {
throw new Error('Attempt to restore backup for not logged in user.');
@@ -69,9 +79,10 @@
return React.useMemo(
() => ({
uploadBackupProtocol,
+ createUserKeysBackup,
retrieveLatestBackupInfo,
}),
- [retrieveLatestBackupInfo, uploadBackupProtocol],
+ [retrieveLatestBackupInfo, uploadBackupProtocol, createUserKeysBackup],
);
}
diff --git a/native/profile/backup-menu.react.js b/native/profile/backup-menu.react.js
--- a/native/profile/backup-menu.react.js
+++ b/native/profile/backup-menu.react.js
@@ -39,7 +39,11 @@
state => state.localSettings.isBackupEnabled,
);
- const { uploadBackupProtocol, retrieveLatestBackupInfo } = useClientBackup();
+ const {
+ uploadBackupProtocol,
+ retrieveLatestBackupInfo,
+ createUserKeysBackup,
+ } = useClientBackup();
const uploadBackup = React.useCallback(async () => {
let message = 'Success';
@@ -52,6 +56,17 @@
Alert.alert('Upload protocol result', message);
}, [uploadBackupProtocol]);
+ const uploadUserKeys = React.useCallback(async () => {
+ let message = 'Success';
+ try {
+ await createUserKeysBackup();
+ } catch (e) {
+ message = `User Keys upload error: ${String(getMessageForException(e))}`;
+ console.error(message);
+ }
+ Alert.alert('Upload User Keys result', message);
+ }, [createUserKeysBackup]);
+
const testRestoreForPasswordUser = React.useCallback(async () => {
let message = 'success';
try {
@@ -161,6 +176,17 @@
<Text style={styles.submenuText}>Test backup upload protocol</Text>
</Button>
</View>
+ <View style={styles.section}>
+ <Button
+ onPress={uploadUserKeys}
+ style={styles.row}
+ iosFormat="highlight"
+ iosHighlightUnderlayColor={colors.panelIosHighlightUnderlay}
+ iosActiveOpacity={0.85}
+ >
+ <Text style={styles.submenuText}>Test User Keys upload</Text>
+ </Button>
+ </View>
<View style={styles.section}>
<Button
onPress={onPressRestoreButton}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 1:14 AM (20 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2553967
Default Alt Text
D13935.diff (3 KB)
Attached To
Mode
D13935: [native] implement creating User Keys backup
Attached
Detach File
Event Timeline
Log In to Comment