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 @@ -14,8 +14,8 @@ import { useSelector } from '../redux/redux-utils.js'; type ClientBackup = { - +createFullBackup: () => Promise, - +createUserKeysBackup: () => Promise, + +createFullBackup: () => Promise, + +createUserKeysBackup: () => Promise, +retrieveLatestBackupInfo: () => Promise, }; @@ -33,7 +33,7 @@ } const backupSecret = await getBackupSecret(); - await commCoreModule.createFullBackup(backupSecret); + return commCoreModule.createFullBackup(backupSecret); }, [loggedIn, currentUserID, getBackupSecret]); const createUserKeysBackup = React.useCallback(async () => { @@ -42,7 +42,7 @@ } const backupSecret = await getBackupSecret(); - await commCoreModule.createUserKeysBackup(backupSecret); + return commCoreModule.createUserKeysBackup(backupSecret); }, [loggedIn, currentUserID, getBackupSecret]); const retrieveLatestBackupInfo = React.useCallback(async () => { diff --git a/native/native_rust_library/src/backup/compaction_upload_promises.rs b/native/native_rust_library/src/backup/compaction_upload_promises.rs --- a/native/native_rust_library/src/backup/compaction_upload_promises.rs +++ b/native/native_rust_library/src/backup/compaction_upload_promises.rs @@ -1,4 +1,4 @@ -use crate::handle_void_result_as_callback; +use crate::handle_string_result_as_callback; use lazy_static::lazy_static; use std::{collections::HashMap, sync::Mutex}; @@ -20,5 +20,11 @@ let Some(promise_id) = backups_to_promises.remove(backup_id) else { return; }; - handle_void_result_as_callback(result, promise_id); + + let result_with_id: Result = match result { + Ok(_) => Ok(backup_id.to_string()), + Err(e) => Err(e), + }; + + handle_string_result_as_callback(result_with_id, promise_id); } 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 @@ -43,9 +43,10 @@ useClientBackup(); const uploadBackup = React.useCallback(async () => { - let message = 'Success'; + let message; try { - await createFullBackup(); + const backupID = await createFullBackup(); + message = `Success!\n` + `Backup ID: ${backupID}`; } catch (e) { message = `Backup upload error: ${String(getMessageForException(e))}`; console.error(message); @@ -54,9 +55,10 @@ }, [createFullBackup]); const uploadUserKeys = React.useCallback(async () => { - let message = 'Success'; + let message; try { - await createUserKeysBackup(); + const backupID = await createUserKeysBackup(); + message = `Success!\n` + `Backup ID: ${backupID}`; } catch (e) { message = `User Keys upload error: ${String(getMessageForException(e))}`; console.error(message); diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js --- a/native/schema/CommCoreModuleSchema.js +++ b/native/schema/CommCoreModuleSchema.js @@ -156,8 +156,8 @@ +clearCommServicesAccessToken: () => Promise; +startBackupHandler: () => void; +stopBackupHandler: () => void; - +createUserKeysBackup: (backupSecret: string) => Promise; - +createFullBackup: (backupSecret: string) => Promise; + +createUserKeysBackup: (backupSecret: string) => Promise; + +createFullBackup: (backupSecret: string) => Promise; +restoreBackup: ( backupSecret: string, maxVersion: string,