Skip to content

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

mobile: fix automatic backups

Ammar Ahmede6db186b620c
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index 056cc23cd..90296470f 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -1176,13 +1176,11 @@ export const settingsGroups: SettingSection[] = [
modifer: async () => {
const user = useUserStore.getState().user;
if (!user || SettingsService.getProperty("encryptedBackup")) {
- await BackupService.run(true, undefined, "partial");
+ await BackupService.run(true);
return;
}
- verifyUser(null, () =>
- BackupService.run(true, undefined, "partial")
- );
+ verifyUser(null, () => BackupService.run(true));
}
},
{
diff --git a/apps/mobile/app/services/backup.ts b/apps/mobile/app/services/backup.ts
index 56948d19b..4130f9a5b 100644
--- a/apps/mobile/app/services/backup.ts
+++ b/apps/mobile/app/services/backup.ts
@@ -150,10 +150,10 @@ async function presentBackupCompleteSheet(backupFilePath: string) {
});
}
-async function updateNextBackupTime() {
+async function updateNextBackupTime(type: "full" | "partial") {
SettingsService.set({
nextBackupRequestTime: Date.now() + 86400000 * 3,
- lastBackupDate: Date.now()
+ [type === "full" ? "lastFullBackupDate" : "lastBackupDate"]: Date.now()
});
}
/**
@@ -164,7 +164,7 @@ async function updateNextBackupTime() {
async function run(
progress = false,
context?: string,
- backupType?: "full" | "partial"
+ backupType: "full" | "partial" = "partial"
) {
console.log("Creating backup:", backupType, progress, context);
@@ -272,7 +272,7 @@ async function run(
RNFetchBlob.fs.unlink(zipOutputFile).catch(console.log);
}
- updateNextBackupTime();
+ updateNextBackupTime(backupType || "partial");
if (progress) {
endProgress();