diff --git a/src/api/vrcPlusImage.js b/src/api/vrcPlusImage.js index fc32e1d1..2ee36ab2 100644 --- a/src/api/vrcPlusImage.js +++ b/src/api/vrcPlusImage.js @@ -43,7 +43,6 @@ const vrcPlusImageReq = { json, params }; - window.API.$emit('PRINT:LIST', args); return args; }); }, diff --git a/src/app.js b/src/app.js index 0e6786c9..d314e878 100644 --- a/src/app.js +++ b/src/app.js @@ -6375,6 +6375,9 @@ console.log(`isLinux: ${LINUX}`); case 'VRCX_udonExceptionLogging': this.udonExceptionLogging = !this.udonExceptionLogging; break; + case 'VRCX_autoDeleteOldPrints': + this.autoDeleteOldPrints = !this.autoDeleteOldPrints; + break; default: break; } @@ -6515,6 +6518,11 @@ console.log(`isLinux: ${LINUX}`); this.udonExceptionLogging ); + await configRepository.setBool( + 'VRCX_autoDeleteOldPrints', + this.autoDeleteOldPrints + ); + this.updateSharedFeed(true); this.updateVRConfigVars(); this.updateVRLastLocation(); @@ -10167,13 +10175,14 @@ console.log(`isLinux: ${LINUX}`); n: 100, tag: 'icon' }; - vrcPlusIconRequest.getFileList(params); + vrcPlusIconRequest.getFileList(params).finally(() => { + this.galleryDialogIconsLoading = false; + }); }; API.$on('FILES:LIST', function (args) { if (args.params.tag === 'icon') { $app.VRCPlusIconsTable = args.json.reverse(); - $app.galleryDialogIconsLoading = false; } }); @@ -10840,13 +10849,14 @@ console.log(`isLinux: ${LINUX}`); n: 100, tag: 'gallery' }; - vrcPlusIconRequest.getFileList(params); + vrcPlusIconRequest.getFileList(params).finally(() => { + this.galleryDialogGalleryLoading = false; + }); }; API.$on('FILES:LIST', function (args) { if (args.params.tag === 'gallery') { $app.galleryTable = args.json.reverse(); - $app.galleryDialogGalleryLoading = false; } }); @@ -10868,13 +10878,14 @@ console.log(`isLinux: ${LINUX}`); n: 100, tag: 'sticker' }; - vrcPlusIconRequest.getFileList(params); + vrcPlusIconRequest.getFileList(params).finally(() => { + this.galleryDialogStickersLoading = false; + }); }; API.$on('FILES:LIST', function (args) { if (args.params.tag === 'sticker') { $app.stickerTable = args.json.reverse(); - $app.galleryDialogStickersLoading = false; } }); @@ -10963,20 +10974,24 @@ console.log(`isLinux: ${LINUX}`); API.$on('LOGIN', function () { $app.printTable = []; + if ($app.autoDeleteOldPrints) { + $app.tryDeleteOldPrints(); + } }); - $app.methods.refreshPrintTable = function () { + $app.methods.refreshPrintTable = async function () { this.galleryDialogPrintsLoading = true; var params = { n: 100 }; - vrcPlusImageRequest.getPrints(params); - }; - - API.$on('PRINT:LIST', function (args) { + const args = await vrcPlusImageRequest.getPrints(params).finally(() => { + this.galleryDialogPrintsLoading = false; + }); + args.json.sort((a, b) => { + return new Date(b.timestamp) - new Date(a.timestamp); + }); $app.printTable = args.json; - $app.galleryDialogPrintsLoading = false; - }); + }; $app.data.printUploadNote = ''; $app.data.printCropBorder = true; @@ -11076,13 +11091,14 @@ console.log(`isLinux: ${LINUX}`); n: 100, tag: 'emoji' }; - vrcPlusIconRequest.getFileList(params); + vrcPlusIconRequest.getFileList(params).finally(() => { + this.galleryDialogEmojisLoading = false; + }); }; API.$on('FILES:LIST', function (args) { if (args.params.tag === 'emoji') { $app.emojiTable = args.json.reverse(); - $app.galleryDialogEmojisLoading = false; } }); @@ -12193,6 +12209,48 @@ console.log(`isLinux: ${LINUX}`); await this.setUGCFolderPath(path); }; + // auto delete old prints + + $app.data.autoDeleteOldPrints = await configRepository.getBool( + 'VRCX_autoDeleteOldPrints', + false + ); + + $app.methods.tryDeleteOldPrints = async function () { + await this.refreshPrintTable(); + const printLimit = 64 - 2; // 2 reserved for new prints + const printCount = $app.printTable.length; + if (printCount <= printLimit) { + return; + } + const deleteCount = printCount - printLimit; + if (deleteCount <= 0) { + return; + } + let idList = []; + for (let i = 0; i < deleteCount; i++) { + const print = $app.printTable[printCount - 1 - i]; + idList.push(print.id); + } + console.log(`Deleting ${deleteCount} old prints`, idList); + try { + for (const printId of idList) { + await vrcPlusImageRequest.deletePrint(printId); + var text = `Old print automaticly deleted: ${printId}`; + if (this.errorNoty) { + this.errorNoty.close(); + } + this.errorNoty = new Noty({ + type: 'info', + text + }).show(); + } + } catch (err) { + console.error('Failed to delete old print:', err); + } + await this.refreshPrintTable(); + }; + // avatar database provider $app.data.isAvatarProviderDialogVisible = false; diff --git a/src/classes/apiRequestHandler.js b/src/classes/apiRequestHandler.js index e692cfd5..64761c9e 100644 --- a/src/classes/apiRequestHandler.js +++ b/src/classes/apiRequestHandler.js @@ -77,6 +77,9 @@ export default class extends baseClass { }) .then((response) => { if (!response.data) { + if ($app.debugWebRequests) { + console.log(init, response); + } return response; } try { diff --git a/src/classes/websocket.js b/src/classes/websocket.js index 90a8d597..a0886bc7 100644 --- a/src/classes/websocket.js +++ b/src/classes/websocket.js @@ -539,16 +539,20 @@ export default class extends baseClass { ) { $app.refreshEmojiTable(); } - } else if ( - contentType === 'print' || - contentType === 'prints' - ) { + } else if (contentType === 'print') { if ( + $app.autoDeleteOldPrints && + content.actionType === 'created' + ) { + $app.tryDeleteOldPrints(); + } else if ( $app.galleryDialogVisible && !$app.galleryDialogPrintsLoading ) { $app.refreshPrintTable(); } + } else if (contentType === 'prints') { + // lol } else if (contentType === 'avatar') { // hmm, utilizing this might be too spamy and cause UI to move around } else if (contentType === 'world') { diff --git a/src/components/dialogs/UserDialog/GalleryDialog.vue b/src/components/dialogs/UserDialog/GalleryDialog.vue index 8bf4d2f3..33e3c967 100644 --- a/src/components/dialogs/UserDialog/GalleryDialog.vue +++ b/src/components/dialogs/UserDialog/GalleryDialog.vue @@ -452,6 +452,14 @@

+
+ + + {{ t('dialog.gallery_icons.refresh') }} + + +
+
@@ -2059,6 +2060,7 @@ 'refreshStickerTable', 'refreshEmojiTable', 'refreshPrintTable', + 'getInventory', 'closeGalleryDialog' ]); @@ -3290,4 +3292,7 @@ function refreshPrintTable() { emit('refreshPrintTable'); } + function getInventory() { + emit('getInventory'); + } diff --git a/src/localization/en/en.json b/src/localization/en/en.json index c4b83f39..7e15e990 100644 --- a/src/localization/en/en.json +++ b/src/localization/en/en.json @@ -522,7 +522,9 @@ "header": "Pictures", "open_folder": "Open Folder", "vrc_photos": "VRChat Photos", - "steam_screenshots": "Steam Screenshots" + "steam_screenshots": "Steam Screenshots", + "auto_delete_old_prints": "Auto Delete Old Prints", + "auto_delete_prints_from_vrc": "Delete Old Prints from VRC when reaching print limit" } }, "advanced": { diff --git a/src/mixins/dialogs/dialogs.pug b/src/mixins/dialogs/dialogs.pug index 9733a264..a304cda2 100644 --- a/src/mixins/dialogs/dialogs.pug +++ b/src/mixins/dialogs/dialogs.pug @@ -102,6 +102,7 @@ mixin dialogs @refreshStickerTable='refreshStickerTable' @refreshVRCPlusIconsTable='refreshVRCPlusIconsTable' @refreshPrintTable='refreshPrintTable' + @getInventory='getInventory' @sortUserDialogAvatars='sortUserDialogAvatars' @logout='logout' @showAvatarAuthorDialog='showAvatarAuthorDialog' diff --git a/src/mixins/tabs/settings.pug b/src/mixins/tabs/settings.pug index 6d4b6e0d..726cee6a 100644 --- a/src/mixins/tabs/settings.pug +++ b/src/mixins/tabs/settings.pug @@ -818,6 +818,16 @@ mixin settingsTab @change='saveScreenshotHelper("VRCX_screenshotHelperCopyToClipboard")' :long-label='true') + //- Pictures | Auto Delete Old Prints + .options-container + span.header {{ $t('view.settings.pictures.pictures.auto_delete_old_prints') }} + .options-container-item(style='margin-top: 0') + simple-switch( + :label='$t("view.settings.pictures.pictures.auto_delete_prints_from_vrc")' + :value='autoDeleteOldPrints' + @change='saveOpenVROption("VRCX_autoDeleteOldPrints")' + :long-label='true') + //- Pictures | User Generated Content .options-container span.header {{ $t('view.settings.advanced.advanced.user_generated_content.header') }}