mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: show progress when restoring encrypted backups
This commit is contained in:
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user