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

View File

@@ -43,7 +43,6 @@ const vrcPlusImageReq = {
json,
params
};
window.API.$emit('PRINT:LIST', args);
return args;
});
},

View File

@@ -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;

View File

@@ -77,6 +77,9 @@ export default class extends baseClass {
})
.then((response) => {
if (!response.data) {
if ($app.debugWebRequests) {
console.log(init, response);
}
return response;
}
try {

View File

@@ -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') {

View File

@@ -452,6 +452,14 @@
</span>
<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
class="x-friend-item"
v-for="item in inventoryTable"
@@ -577,6 +585,7 @@
'refreshStickerTable',
'refreshEmojiTable',
'refreshPrintTable',
'getInventory',
'closeGalleryDialog'
]);
@@ -1058,6 +1067,10 @@
emit('refreshPrintTable');
}
function getInventory() {
emit('getInventory');
}
function displayPrintUpload() {
document.getElementById('PrintUploadButton').click();
}
@@ -1090,7 +1103,7 @@
break;
}
}
this.getInventory();
getInventory();
} catch (error) {
console.error('Error consuming inventory bundle:', error);
}

View File

@@ -1812,6 +1812,7 @@
@refreshStickerTable="refreshStickerTable"
@refreshEmojiTable="refreshEmojiTable"
@refreshPrintTable="refreshPrintTable"
@getInventory="getInventory"
@closeGalleryDialog="closeGalleryDialog" />
</safe-dialog>
</template>
@@ -2059,6 +2060,7 @@
'refreshStickerTable',
'refreshEmojiTable',
'refreshPrintTable',
'getInventory',
'closeGalleryDialog'
]);
@@ -3290,4 +3292,7 @@
function refreshPrintTable() {
emit('refreshPrintTable');
}
function getInventory() {
emit('getInventory');
}
</script>

View File

@@ -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": {

View File

@@ -102,6 +102,7 @@ mixin dialogs
@refreshStickerTable='refreshStickerTable'
@refreshVRCPlusIconsTable='refreshVRCPlusIconsTable'
@refreshPrintTable='refreshPrintTable'
@getInventory='getInventory'
@sortUserDialogAvatars='sortUserDialogAvatars'
@logout='logout'
@showAvatarAuthorDialog='showAvatarAuthorDialog'

View File

@@ -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') }}