From ec9c7f8671a87ce617e23e96ae5a49b3e350290f Mon Sep 17 00:00:00 2001 From: Index Date: Sat, 6 Jul 2024 06:27:57 -0500 Subject: [PATCH] fix: LoadItems() overwriting item cache avatar sandbox --- js/account/avatar-sandbox.js | 46 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/js/account/avatar-sandbox.js b/js/account/avatar-sandbox.js index b967a47..c178e0c 100644 --- a/js/account/avatar-sandbox.js +++ b/js/account/avatar-sandbox.js @@ -500,29 +500,31 @@ async function LoadItems() { ` document.getElementById('inventory').appendChild(ItemColumn) - ItemCache[item.id] = { - type: item.type, - name: item.name, - price: item.price, - creator: { - name: item.creator.name, - id: item.creator.id - }, - thumbnail: item.thumbnail, - asset: undefined - } - - if (item.price === 0) { - if (item.sales === 0) { - console.log("ITEM IS AWARD-ONLY!!! ", item) - ItemCache[item.id].price = null - } else { - ItemCache[item.id].price = 0 + if (ItemCache[item.id] === undefined) { + ItemCache[item.id] = { + type: item.type, + name: item.name, + price: item.price, + creator: { + name: item.creator.name, + id: item.creator.id + }, + thumbnail: item.thumbnail, + asset: undefined + } + + if (item.price === 0) { + if (item.sales === 0) { + console.log("ITEM IS AWARD-ONLY!!! ", item) + ItemCache[item.id].price = null + } else { + ItemCache[item.id].price = 0 + } + } + + if (item.type === 'hat') { + ItemCache[item.id].accessoryType = item.accessoryType } - } - - if (item.type === 'hat') { - ItemCache[item.id].accessoryType = item.accessoryType } ItemColumn.getElementsByClassName('p-2')[0].addEventListener('click', function(){