mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
VRC reg auto back every 3days
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -111,6 +111,7 @@ export const useUpdateLoopStore = defineStore('UpdateLoop', () => {
|
||||
if (vrcxUpdaterStore.autoUpdateVRCX !== 'Off') {
|
||||
vrcxUpdaterStore.checkForVRCXUpdate();
|
||||
}
|
||||
vrcxStore.tryAutoBackupVrcRegistry();
|
||||
}
|
||||
if (--state.ipcTimeout <= 0) {
|
||||
vrcxStore.ipcEnabled = false;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user