From 70b34f67722225c8cd4b0a9447d0fbc3d05d445a Mon Sep 17 00:00:00 2001 From: Natsumi Date: Sat, 15 Jan 2022 15:57:35 +1300 Subject: [PATCH] Auto clear VRCX cache --- html/src/app.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++ html/src/index.pug | 1 + 2 files changed, 53 insertions(+) diff --git a/html/src/app.js b/html/src/app.js index 7bdb428a..8f676ae8 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -4039,6 +4039,8 @@ speechSynthesis.getVoices(); nextCurrentUserRefresh: 0, nextFriendsRefresh: 0, nextAppUpdateCheck: 0, + ipcTimeout: 0, + nextClearVRCXCacheCheck: 0, isGameRunning: false, isGameNoVR: false, isSteamVRRunning: false, @@ -4143,6 +4145,13 @@ speechSynthesis.getVoices(); if (--this.ipcTimeout <= 0) { this.ipcEnabled = false; } + if ( + --this.nextClearVRCXCacheCheck <= 0 && + this.clearVRCXCacheFrequency > 0 + ) { + this.nextClearVRCXCacheCheck = this.clearVRCXCacheFrequency; + this.clearVRCXCache(); + } AppApi.CheckGameRunning().then( ([isGameRunning, isGameNoVR, isSteamVRRunning]) => { this.updateOpenVR( @@ -10955,6 +10964,12 @@ speechSynthesis.getVoices(); $app.data.photonLobbyTimeoutThreshold = configRepository.getString( 'VRCX_photonLobbyTimeoutThreshold' ); + $app.data.clearVRCXCacheFrequency = configRepository.getString( + 'VRCX_clearVRCXCacheFrequency' + ); + $app.data.nextClearVRCXCacheCheck = configRepository.getString( + 'VRCX_clearVRCXCacheFrequency' + ); $app.methods.saveOpenVROption = function () { configRepository.setBool('openVR', this.openVR); configRepository.setBool('openVRAlways', this.openVRAlways); @@ -11243,6 +11258,13 @@ speechSynthesis.getVoices(); $app.data.photonLobbyTimeoutThreshold ); } + if (!configRepository.getString('VRCX_clearVRCXCacheFrequency')) { + $app.data.clearVRCXCacheFrequency = 172800; // 24 hours + configRepository.setString( + 'VRCX_clearVRCXCacheFrequency', + $app.data.clearVRCXCacheFrequency + ); + } if (!configRepository.getString('VRCX_TimeoutHudOverlayFilter')) { $app.data.timeoutHudOverlayFilter = 'Everyone'; configRepository.setString( @@ -12116,6 +12138,36 @@ speechSynthesis.getVoices(); ); }; + $app.methods.promptAutoClearVRCXCacheFrequency = function () { + this.$prompt( + 'Enter amount of hours (default: 24, disabled: 0)', + 'Clear VRCX Cache Timer', + { + distinguishCancelAndClose: true, + confirmButtonText: 'OK', + cancelButtonText: 'Cancel', + inputValue: this.clearVRCXCacheFrequency / 3600 / 2, + inputPattern: /\d+$/, + inputErrorMessage: 'Valid number is required', + callback: (action, instance) => { + if ( + action === 'confirm' && + instance.inputValue && + !isNaN(instance.inputValue) + ) { + this.clearVRCXCacheFrequency = Math.trunc( + Number(instance.inputValue) * 3600 * 2 + ); + configRepository.setString( + 'VRCX_clearVRCXCacheFrequency', + this.clearVRCXCacheFrequency + ); + } + } + } + ); + }; + // App: Dialog var adjustDialogZ = (el) => { diff --git a/html/src/index.pug b/html/src/index.pug index ee3d10df..9ca3c3e1 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -1190,6 +1190,7 @@ html span.name Avatar Name cache: #[span(v-text="API.cachedAvatarNames.size")] div.options-container-item el-button(size="small" icon="el-icon-delete-solid" @click="clearVRCXCache") Clear Cache + el-button(size="small" icon="el-icon-time" @click="promptAutoClearVRCXCacheFrequency") Auto Clear Cache div.options-container-item el-button(size="small" icon="el-icon-tickets" @click="showConsole") Show Console div.options-container