mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 14:56:06 +02:00
Fix saving instance stickers
This commit is contained in:
+14
-8
@@ -1341,25 +1341,31 @@ namespace VRCX
|
|||||||
|
|
||||||
private bool ParseStickerSpawn(FileInfo fileInfo, LogContext logContext, string line, int offset)
|
private bool ParseStickerSpawn(FileInfo fileInfo, LogContext logContext, string line, int offset)
|
||||||
{
|
{
|
||||||
|
// [StickersManager] User usr_032383a7-748c-4fb2-94e4-bcb928e5de6b (Natsumi-sama) spawned sticker inv_8b380ee4-9a8a-484e-a0c3-b01290b92c6a
|
||||||
var index = line.IndexOf("[StickersManager] User ", StringComparison.Ordinal);
|
var index = line.IndexOf("[StickersManager] User ", StringComparison.Ordinal);
|
||||||
if (index == -1 || !line.Contains("file_") || !line.Contains("spawned sticker"))
|
if (index == -1 || !line.Contains("inv_") || !line.Contains("spawned sticker"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
string info = line.Substring(index + 23);
|
var info = line.Substring(index + 23);
|
||||||
|
|
||||||
var (userId, displayName) = ParseUserInfo(info);
|
var (userId, displayName) = ParseUserInfo(info); // it's flipped
|
||||||
|
if (string.IsNullOrEmpty(displayName) && string.IsNullOrEmpty(userId))
|
||||||
|
{
|
||||||
|
logger.Warn("Failed to parse user info from log line: {0}", line);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var fileIdIndex = info.IndexOf("file_", StringComparison.Ordinal);
|
var inventoryIdIndex = info.IndexOf("inv_", StringComparison.Ordinal);
|
||||||
string fileId = info.Substring(fileIdIndex);
|
var inventoryId = info.Substring(inventoryIdIndex);
|
||||||
|
|
||||||
AppendLog(new[]
|
AppendLog(new[]
|
||||||
{
|
{
|
||||||
fileInfo.Name,
|
fileInfo.Name,
|
||||||
ConvertLogTimeToISO8601(line),
|
ConvertLogTimeToISO8601(line),
|
||||||
"sticker-spawn",
|
"sticker-spawn",
|
||||||
userId,
|
userId ?? string.Empty,
|
||||||
displayName,
|
displayName ?? string.Empty,
|
||||||
fileId,
|
inventoryId
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+21
-13
@@ -10918,23 +10918,31 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$app.data.stickersCache = [];
|
$app.data.instanceStickersCache = [];
|
||||||
|
|
||||||
$app.methods.trySaveStickerToFile = async function (displayName, fileId) {
|
$app.methods.trySaveStickerToFile = async function (
|
||||||
if ($app.stickersCache.includes(fileId)) return;
|
displayName,
|
||||||
$app.stickersCache.push(fileId);
|
inventoryId
|
||||||
if ($app.stickersCache.size > 100) {
|
) {
|
||||||
$app.stickersCache.shift();
|
if (this.instanceStickersCache.includes(inventoryId)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
var args = await API.call(`file/${fileId}`);
|
this.instanceStickersCache.push(inventoryId);
|
||||||
var imageUrl = args.versions[1].file.url;
|
if (this.instanceStickersCache.size > 100) {
|
||||||
var createdAt = args.versions[0].created_at;
|
this.instanceStickersCache.shift();
|
||||||
|
}
|
||||||
|
var args = await inventoryRequest.getInventoryItem({
|
||||||
|
inventoryId
|
||||||
|
});
|
||||||
|
|
||||||
|
var imageUrl = args.json.metadata?.imageUrl ?? args.json.imageUrl;
|
||||||
|
var createdAt = args.json.created_at;
|
||||||
var monthFolder = createdAt.slice(0, 7);
|
var monthFolder = createdAt.slice(0, 7);
|
||||||
var fileNameDate = createdAt
|
var fileNameDate = createdAt
|
||||||
.replace(/:/g, '-')
|
.replace(/:/g, '-')
|
||||||
.replace(/T/g, '_')
|
.replace(/T/g, '_')
|
||||||
.replace(/Z/g, '');
|
.replace(/Z/g, '');
|
||||||
var fileName = `${displayName}_${fileNameDate}_${fileId}.png`;
|
var fileName = `${displayName}_${fileNameDate}_${inventoryId}.png`;
|
||||||
var filePath = await AppApi.SaveStickerToFile(
|
var filePath = await AppApi.SaveStickerToFile(
|
||||||
imageUrl,
|
imageUrl,
|
||||||
this.ugcFolderPath,
|
this.ugcFolderPath,
|
||||||
@@ -11032,7 +11040,7 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
|
|
||||||
$app.data.printCache = [];
|
$app.data.printCache = [];
|
||||||
$app.data.printQueue = [];
|
$app.data.printQueue = [];
|
||||||
$app.data.printQueueWorker = undefined;
|
$app.data.printQueueWorker = null;
|
||||||
|
|
||||||
$app.methods.queueSavePrintToFile = function (printId) {
|
$app.methods.queueSavePrintToFile = function (printId) {
|
||||||
if (this.printCache.includes(printId)) {
|
if (this.printCache.includes(printId)) {
|
||||||
@@ -11091,9 +11099,9 @@ console.log(`isLinux: ${LINUX}`);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.printQueue.length == 0) {
|
if (this.printQueue.length === 0) {
|
||||||
workerTimers.clearInterval(this.printQueueWorker);
|
workerTimers.clearInterval(this.printQueueWorker);
|
||||||
this.printQueueWorker = undefined;
|
this.printQueueWorker = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ export default class extends baseClass {
|
|||||||
|
|
||||||
$app.trySaveStickerToFile(
|
$app.trySaveStickerToFile(
|
||||||
gameLog.displayName,
|
gameLog.displayName,
|
||||||
gameLog.fileId
|
gameLog.inventoryId
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -539,6 +539,8 @@ export default class extends baseClass {
|
|||||||
) {
|
) {
|
||||||
$app.refreshEmojiTable();
|
$app.refreshEmojiTable();
|
||||||
}
|
}
|
||||||
|
} else if (contentType === 'sticker') {
|
||||||
|
// on sticker upload
|
||||||
} else if (contentType === 'print') {
|
} else if (contentType === 'print') {
|
||||||
if (
|
if (
|
||||||
$app.autoDeleteOldPrints &&
|
$app.autoDeleteOldPrints &&
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class GameLogService {
|
|||||||
case 'sticker-spawn':
|
case 'sticker-spawn':
|
||||||
gameLog.userId = args[0];
|
gameLog.userId = args[0];
|
||||||
gameLog.displayName = args[1];
|
gameLog.displayName = args[1];
|
||||||
gameLog.fileId = args[2];
|
gameLog.inventoryId = args[2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user