Auto Delete Old Prints

This commit is contained in:
Natsumi
2025-06-20 17:43:22 +12:00
parent 86026f5189
commit 84913a0ef6
9 changed files with 117 additions and 22 deletions
-1
View File
@@ -43,7 +43,6 @@ const vrcPlusImageReq = {
json, json,
params params
}; };
window.API.$emit('PRINT:LIST', args);
return args; return args;
}); });
}, },
+73 -15
View File
@@ -6375,6 +6375,9 @@ console.log(`isLinux: ${LINUX}`);
case 'VRCX_udonExceptionLogging': case 'VRCX_udonExceptionLogging':
this.udonExceptionLogging = !this.udonExceptionLogging; this.udonExceptionLogging = !this.udonExceptionLogging;
break; break;
case 'VRCX_autoDeleteOldPrints':
this.autoDeleteOldPrints = !this.autoDeleteOldPrints;
break;
default: default:
break; break;
} }
@@ -6515,6 +6518,11 @@ console.log(`isLinux: ${LINUX}`);
this.udonExceptionLogging this.udonExceptionLogging
); );
await configRepository.setBool(
'VRCX_autoDeleteOldPrints',
this.autoDeleteOldPrints
);
this.updateSharedFeed(true); this.updateSharedFeed(true);
this.updateVRConfigVars(); this.updateVRConfigVars();
this.updateVRLastLocation(); this.updateVRLastLocation();
@@ -10167,13 +10175,14 @@ console.log(`isLinux: ${LINUX}`);
n: 100, n: 100,
tag: 'icon' tag: 'icon'
}; };
vrcPlusIconRequest.getFileList(params); vrcPlusIconRequest.getFileList(params).finally(() => {
this.galleryDialogIconsLoading = false;
});
}; };
API.$on('FILES:LIST', function (args) { API.$on('FILES:LIST', function (args) {
if (args.params.tag === 'icon') { if (args.params.tag === 'icon') {
$app.VRCPlusIconsTable = args.json.reverse(); $app.VRCPlusIconsTable = args.json.reverse();
$app.galleryDialogIconsLoading = false;
} }
}); });
@@ -10840,13 +10849,14 @@ console.log(`isLinux: ${LINUX}`);
n: 100, n: 100,
tag: 'gallery' tag: 'gallery'
}; };
vrcPlusIconRequest.getFileList(params); vrcPlusIconRequest.getFileList(params).finally(() => {
this.galleryDialogGalleryLoading = false;
});
}; };
API.$on('FILES:LIST', function (args) { API.$on('FILES:LIST', function (args) {
if (args.params.tag === 'gallery') { if (args.params.tag === 'gallery') {
$app.galleryTable = args.json.reverse(); $app.galleryTable = args.json.reverse();
$app.galleryDialogGalleryLoading = false;
} }
}); });
@@ -10868,13 +10878,14 @@ console.log(`isLinux: ${LINUX}`);
n: 100, n: 100,
tag: 'sticker' tag: 'sticker'
}; };
vrcPlusIconRequest.getFileList(params); vrcPlusIconRequest.getFileList(params).finally(() => {
this.galleryDialogStickersLoading = false;
});
}; };
API.$on('FILES:LIST', function (args) { API.$on('FILES:LIST', function (args) {
if (args.params.tag === 'sticker') { if (args.params.tag === 'sticker') {
$app.stickerTable = args.json.reverse(); $app.stickerTable = args.json.reverse();
$app.galleryDialogStickersLoading = false;
} }
}); });
@@ -10963,20 +10974,24 @@ console.log(`isLinux: ${LINUX}`);
API.$on('LOGIN', function () { API.$on('LOGIN', function () {
$app.printTable = []; $app.printTable = [];
if ($app.autoDeleteOldPrints) {
$app.tryDeleteOldPrints();
}
}); });
$app.methods.refreshPrintTable = function () { $app.methods.refreshPrintTable = async function () {
this.galleryDialogPrintsLoading = true; this.galleryDialogPrintsLoading = true;
var params = { var params = {
n: 100 n: 100
}; };
vrcPlusImageRequest.getPrints(params); const args = await vrcPlusImageRequest.getPrints(params).finally(() => {
}; this.galleryDialogPrintsLoading = false;
API.$on('PRINT:LIST', function (args) {
$app.printTable = args.json;
$app.galleryDialogPrintsLoading = false;
}); });
args.json.sort((a, b) => {
return new Date(b.timestamp) - new Date(a.timestamp);
});
$app.printTable = args.json;
};
$app.data.printUploadNote = ''; $app.data.printUploadNote = '';
$app.data.printCropBorder = true; $app.data.printCropBorder = true;
@@ -11076,13 +11091,14 @@ console.log(`isLinux: ${LINUX}`);
n: 100, n: 100,
tag: 'emoji' tag: 'emoji'
}; };
vrcPlusIconRequest.getFileList(params); vrcPlusIconRequest.getFileList(params).finally(() => {
this.galleryDialogEmojisLoading = false;
});
}; };
API.$on('FILES:LIST', function (args) { API.$on('FILES:LIST', function (args) {
if (args.params.tag === 'emoji') { if (args.params.tag === 'emoji') {
$app.emojiTable = args.json.reverse(); $app.emojiTable = args.json.reverse();
$app.galleryDialogEmojisLoading = false;
} }
}); });
@@ -12193,6 +12209,48 @@ console.log(`isLinux: ${LINUX}`);
await this.setUGCFolderPath(path); 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 // avatar database provider
$app.data.isAvatarProviderDialogVisible = false; $app.data.isAvatarProviderDialogVisible = false;
+3
View File
@@ -77,6 +77,9 @@ export default class extends baseClass {
}) })
.then((response) => { .then((response) => {
if (!response.data) { if (!response.data) {
if ($app.debugWebRequests) {
console.log(init, response);
}
return response; return response;
} }
try { try {
+8 -4
View File
@@ -539,16 +539,20 @@ export default class extends baseClass {
) { ) {
$app.refreshEmojiTable(); $app.refreshEmojiTable();
} }
} else if ( } else if (contentType === 'print') {
contentType === 'print' ||
contentType === 'prints'
) {
if ( if (
$app.autoDeleteOldPrints &&
content.actionType === 'created'
) {
$app.tryDeleteOldPrints();
} else if (
$app.galleryDialogVisible && $app.galleryDialogVisible &&
!$app.galleryDialogPrintsLoading !$app.galleryDialogPrintsLoading
) { ) {
$app.refreshPrintTable(); $app.refreshPrintTable();
} }
} else if (contentType === 'prints') {
// lol
} else if (contentType === 'avatar') { } else if (contentType === 'avatar') {
// hmm, utilizing this might be too spamy and cause UI to move around // hmm, utilizing this might be too spamy and cause UI to move around
} else if (contentType === 'world') { } else if (contentType === 'world') {
@@ -452,6 +452,14 @@
</span> </span>
<br /> <br />
<br /> <br />
<div style="display: flex; align-items: center">
<el-button-group>
<el-button type="default" size="small" @click="getInventory" icon="el-icon-refresh">
{{ t('dialog.gallery_icons.refresh') }}
</el-button>
</el-button-group>
</div>
<br />
<div <div
class="x-friend-item" class="x-friend-item"
v-for="item in inventoryTable" v-for="item in inventoryTable"
@@ -577,6 +585,7 @@
'refreshStickerTable', 'refreshStickerTable',
'refreshEmojiTable', 'refreshEmojiTable',
'refreshPrintTable', 'refreshPrintTable',
'getInventory',
'closeGalleryDialog' 'closeGalleryDialog'
]); ]);
@@ -1058,6 +1067,10 @@
emit('refreshPrintTable'); emit('refreshPrintTable');
} }
function getInventory() {
emit('getInventory');
}
function displayPrintUpload() { function displayPrintUpload() {
document.getElementById('PrintUploadButton').click(); document.getElementById('PrintUploadButton').click();
} }
@@ -1090,7 +1103,7 @@
break; break;
} }
} }
this.getInventory(); getInventory();
} catch (error) { } catch (error) {
console.error('Error consuming inventory bundle:', error); console.error('Error consuming inventory bundle:', error);
} }
@@ -1812,6 +1812,7 @@
@refreshStickerTable="refreshStickerTable" @refreshStickerTable="refreshStickerTable"
@refreshEmojiTable="refreshEmojiTable" @refreshEmojiTable="refreshEmojiTable"
@refreshPrintTable="refreshPrintTable" @refreshPrintTable="refreshPrintTable"
@getInventory="getInventory"
@closeGalleryDialog="closeGalleryDialog" /> @closeGalleryDialog="closeGalleryDialog" />
</safe-dialog> </safe-dialog>
</template> </template>
@@ -2059,6 +2060,7 @@
'refreshStickerTable', 'refreshStickerTable',
'refreshEmojiTable', 'refreshEmojiTable',
'refreshPrintTable', 'refreshPrintTable',
'getInventory',
'closeGalleryDialog' 'closeGalleryDialog'
]); ]);
@@ -3290,4 +3292,7 @@
function refreshPrintTable() { function refreshPrintTable() {
emit('refreshPrintTable'); emit('refreshPrintTable');
} }
function getInventory() {
emit('getInventory');
}
</script> </script>
+3 -1
View File
@@ -522,7 +522,9 @@
"header": "Pictures", "header": "Pictures",
"open_folder": "Open Folder", "open_folder": "Open Folder",
"vrc_photos": "VRChat Photos", "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": { "advanced": {
+1
View File
@@ -102,6 +102,7 @@ mixin dialogs
@refreshStickerTable='refreshStickerTable' @refreshStickerTable='refreshStickerTable'
@refreshVRCPlusIconsTable='refreshVRCPlusIconsTable' @refreshVRCPlusIconsTable='refreshVRCPlusIconsTable'
@refreshPrintTable='refreshPrintTable' @refreshPrintTable='refreshPrintTable'
@getInventory='getInventory'
@sortUserDialogAvatars='sortUserDialogAvatars' @sortUserDialogAvatars='sortUserDialogAvatars'
@logout='logout' @logout='logout'
@showAvatarAuthorDialog='showAvatarAuthorDialog' @showAvatarAuthorDialog='showAvatarAuthorDialog'
+10
View File
@@ -818,6 +818,16 @@ mixin settingsTab
@change='saveScreenshotHelper("VRCX_screenshotHelperCopyToClipboard")' @change='saveScreenshotHelper("VRCX_screenshotHelperCopyToClipboard")'
:long-label='true') :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 //- Pictures | User Generated Content
.options-container .options-container
span.header {{ $t('view.settings.advanced.advanced.user_generated_content.header') }} span.header {{ $t('view.settings.advanced.advanced.user_generated_content.header') }}