diff --git a/src/localization/en/en.json b/src/localization/en/en.json index 5419fe5d..7d62329b 100644 --- a/src/localization/en/en.json +++ b/src/localization/en/en.json @@ -381,7 +381,7 @@ "theme_mode_dark": "Dark", "theme_mode_blue": "Blue", "theme_mode_darkblue": "Dark Blue", - "theme_mode_amoled" : "Amoled", + "theme_mode_amoled": "Amoled", "theme_mode_darkvanillaold": "Dark Vanilla (old)", "theme_mode_darkvanilla": "Dark Vanilla", "theme_mode_pink": "Pink", @@ -1554,7 +1554,7 @@ "name": "Name", "date": "Date", "action": "Action", - "auto_backup": "Weekly Auto Backup", + "auto_backup": "Auto backup every 3 days (deletes after 2 weeks)", "restore_prompt": "VRCX has noticed auto backup of VRC registry settings is enabled but this computer doesn't have any, if you'd like to restore from backup you can do so from here." }, "group_member_moderation": { diff --git a/src/stores/updateLoop.js b/src/stores/updateLoop.js index 3e7fcb19..b4371f4f 100644 --- a/src/stores/updateLoop.js +++ b/src/stores/updateLoop.js @@ -111,6 +111,7 @@ export const useUpdateLoopStore = defineStore('UpdateLoop', () => { if (vrcxUpdaterStore.autoUpdateVRCX !== 'Off') { vrcxUpdaterStore.checkForVRCXUpdate(); } + vrcxStore.tryAutoBackupVrcRegistry(); } if (--state.ipcTimeout <= 0) { vrcxStore.ipcEnabled = false; diff --git a/src/stores/vrcx.js b/src/stores/vrcx.js index 89e5c247..f3f8a347 100644 --- a/src/stores/vrcx.js +++ b/src/stores/vrcx.js @@ -707,7 +707,7 @@ export const useVrcxStore = defineStore('Vrcx', () => { lastBackupDate ); } else { - await autoBackupVrcRegistry(); + await tryAutoBackupVrcRegistry(); } } @@ -715,7 +715,10 @@ export const useVrcxStore = defineStore('Vrcx', () => { state.isRegistryBackupDialogVisible = true; } - async function autoBackupVrcRegistry() { + async function tryAutoBackupVrcRegistry() { + if (!advancedSettingsStore.vrcRegistryAutoBackup) { + return; + } const date = new Date(); const lastBackupDate = await configRepository.getString( 'VRCX_VRChatRegistryLastBackupDate' @@ -724,7 +727,7 @@ export const useVrcxStore = defineStore('Vrcx', () => { const lastBackup = new Date(lastBackupDate); const diff = date.getTime() - lastBackup.getTime(); const diffDays = Math.floor(diff / (1000 * 60 * 60 * 24)); - if (diffDays < 7) { + if (diffDays < 3) { return; } } @@ -735,12 +738,16 @@ export const useVrcxStore = defineStore('Vrcx', () => { backupsJson = JSON.stringify([]); } const backups = JSON.parse(backupsJson); - backups.forEach((backup) => { - if (backup.name === 'Auto Backup') { - // remove old auto backup - removeFromArray(backups, backup); + for (let i = backups.length - 1; i >= 0; i--) { + const backupDate = new Date(backups[i].date); + // remove backups older than 2 weeks + if ( + backups[i].name === 'Auto Backup' && + backupDate.getTime() < date.getTime() - 1209600000 // 2 weeks in milliseconds + ) { + backups.splice(i, 1); } - }); + } await configRepository.setString( 'VRCX_VRChatRegistryBackups', JSON.stringify(backups) @@ -766,6 +773,7 @@ export const useVrcxStore = defineStore('Vrcx', () => { eventVrcxMessage, showRegistryBackupDialog, checkAutoBackupRestoreVrcRegistry, + tryAutoBackupVrcRegistry, processScreenshot, ipcEvent, dragEnterCef,