mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 06:46:04 +02:00
Save instance emojis
This commit is contained in:
+84
@@ -32,6 +32,7 @@ import {
|
||||
groupRequest,
|
||||
imageRequest,
|
||||
instanceRequest,
|
||||
inventoryRequest,
|
||||
inviteMessagesRequest,
|
||||
miscRequest,
|
||||
notificationRequest,
|
||||
@@ -119,6 +120,7 @@ import { userDialogGroupSortingOptions } from './composables/user/constants/user
|
||||
import {
|
||||
getPrintFileName,
|
||||
getPrintLocalDate,
|
||||
getEmojiFileName,
|
||||
languageClass
|
||||
} from './composables/user/utils';
|
||||
import InteropApi from './ipc-electron/interopApi.js';
|
||||
@@ -6768,6 +6770,9 @@ console.log(`isLinux: ${LINUX}`);
|
||||
case 'VRCX_saveInstanceStickers':
|
||||
this.saveInstanceStickers = !this.saveInstanceStickers;
|
||||
break;
|
||||
case 'VRCX_saveInstanceEmoji':
|
||||
this.saveInstanceEmoji = !this.saveInstanceEmoji;
|
||||
break;
|
||||
case 'VRCX_StartAsMinimizedState':
|
||||
this.isStartAsMinimizedState = !this.isStartAsMinimizedState;
|
||||
break;
|
||||
@@ -6808,6 +6813,11 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.saveInstanceStickers
|
||||
);
|
||||
|
||||
await configRepository.setBool(
|
||||
'VRCX_saveInstanceEmoji',
|
||||
this.saveInstanceEmoji
|
||||
);
|
||||
|
||||
VRCXStorage.Set(
|
||||
'VRCX_StartAsMinimizedState',
|
||||
this.isStartAsMinimizedState.toString()
|
||||
@@ -10954,6 +10964,75 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
// #region | Emoji
|
||||
|
||||
$app.data.instanceInventoryCache = [];
|
||||
$app.data.instanceInventoryQueue = [];
|
||||
$app.data.instanceInventoryQueueWorker = null;
|
||||
|
||||
$app.methods.queueCheckInstanceInventory = function (inventoryId) {
|
||||
if (this.instanceInventoryCache.includes(inventoryId)) {
|
||||
return;
|
||||
}
|
||||
this.instanceInventoryCache.push(inventoryId);
|
||||
if (this.instanceInventoryCache.length > 100) {
|
||||
this.instanceInventoryCache.shift();
|
||||
}
|
||||
|
||||
this.instanceInventoryQueue.push(inventoryId);
|
||||
|
||||
if (!this.instanceInventoryQueueWorker) {
|
||||
this.instanceInventoryQueueWorker = workerTimers.setInterval(() => {
|
||||
let inventoryId = this.instanceInventoryQueue.shift();
|
||||
if (inventoryId) {
|
||||
this.trySaveEmojiToFile(inventoryId);
|
||||
}
|
||||
}, 2_500);
|
||||
}
|
||||
};
|
||||
|
||||
$app.methods.trySaveEmojiToFile = async function (inventoryId) {
|
||||
const args = await inventoryRequest.getInventoryItem({
|
||||
inventoryId
|
||||
});
|
||||
|
||||
if (args.json.itemType !== 'emoji') {
|
||||
// Not an emoji, skip
|
||||
return;
|
||||
}
|
||||
|
||||
const userArgs = await userRequest.getCachedUser({
|
||||
userId: args.json.holderId
|
||||
});
|
||||
const displayName = userArgs.json?.displayName ?? '';
|
||||
|
||||
let emoji = args.json.metadata;
|
||||
emoji.name = `${displayName}_${inventoryId}`;
|
||||
|
||||
const emojiFileName = getEmojiFileName(emoji);
|
||||
const imageUrl = args.json.metadata?.imageUrl ?? args.json.imageUrl;
|
||||
const createdAt = args.json.created_at;
|
||||
const monthFolder = createdAt.slice(0, 7);
|
||||
|
||||
const filePath = await AppApi.SaveEmojiToFile(
|
||||
imageUrl,
|
||||
this.ugcFolderPath,
|
||||
monthFolder,
|
||||
emojiFileName
|
||||
);
|
||||
if (filePath) {
|
||||
console.log(
|
||||
`Emoji saved to file: ${monthFolder}\\${emojiFileName}`
|
||||
);
|
||||
}
|
||||
|
||||
if (this.instanceInventoryQueue.length === 0) {
|
||||
workerTimers.clearInterval(this.instanceInventoryQueueWorker);
|
||||
this.instanceInventoryQueueWorker = null;
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
// #region | Prints
|
||||
$app.methods.cropPrintsChanged = function () {
|
||||
@@ -11038,6 +11117,11 @@ console.log(`isLinux: ${LINUX}`);
|
||||
false
|
||||
);
|
||||
|
||||
$app.data.saveInstanceEmoji = await configRepository.getBool(
|
||||
'VRCX_saveInstanceEmoji',
|
||||
false
|
||||
);
|
||||
|
||||
$app.data.printCache = [];
|
||||
$app.data.printQueue = [];
|
||||
$app.data.printQueueWorker = null;
|
||||
|
||||
Reference in New Issue
Block a user