mobile: fix automatic backups

This commit is contained in:
Ammar Ahmed
2024-08-27 16:48:09 +05:00
parent 998e62ade7
commit e6db186b62
2 changed files with 6 additions and 8 deletions

View File

@@ -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));
}
},
{

View File

@@ -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();