Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: show progress when restoring encrypted backups

Abdullah Atta800f983688ea
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index 848abf32e..4399bef39 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -138,36 +138,39 @@ export async function importBackup() {
}
export async function restoreBackupFile(backup) {
- console.log("[restore]", backup);
if (backup.data.iv && backup.data.salt) {
await showPasswordDialog("ask_backup_password", async ({ password }) => {
- const error = await restore(backup, password);
+ const error = await restoreWithProgress(backup, password);
return !error;
});
} else {
- await TaskManager.startTask({
- title: "Restoring backup",
- subtitle: "This might take a while",
- type: "modal",
- action: (report) => {
- db.eventManager.subscribe(
- EVENTS.migrationProgress,
- ({ collection, total, current }) => {
- report({
- text: `Restoring ${collection}...`,
- current,
- total
- });
- }
- );
-
- report({ text: `Restoring...` });
- return restore(backup);
- }
- });
+ await restoreWithProgress(backup);
}
}
+async function restoreWithProgress(backup, password) {
+ await TaskManager.startTask({
+ title: "Restoring backup",
+ subtitle: "This might take a while",
+ type: "modal",
+ action: (report) => {
+ db.eventManager.subscribe(
+ EVENTS.migrationProgress,
+ ({ collection, total, current }) => {
+ report({
+ text: `Restoring ${collection}...`,
+ current,
+ total
+ });
+ }
+ );
+
+ report({ text: `Restoring...` });
+ return restore(backup, password);
+ }
+ });
+}
+
export async function verifyAccount() {
if (!(await db.user.getUser())) return true;
return showPasswordDialog("verify_account", ({ password }) => {