fix: fix loading privated assets in avatar sandbox

This commit is contained in:
Index 2024-07-06 06:28:20 -05:00
parent ec9c7f8671
commit d86f928b6f

View file

@ -292,21 +292,33 @@ async function UpdateAvatar() {
const AccessoryPromise = [...Avatar.items, Avatar.tool, Avatar.torso].filter((x) => x !== undefined && !x.toString().startsWith('http') && !x.toString().startsWith('data:')).map(async (x, index) => { const AccessoryPromise = [...Avatar.items, Avatar.tool, Avatar.torso].filter((x) => x !== undefined && !x.toString().startsWith('http') && !x.toString().startsWith('data:')).map(async (x, index) => {
if (ItemCache[x] === undefined) { if (ItemCache[x] === undefined) {
const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json()) try {
ItemCache[x] = { const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json())
type: ItemDetails.type, ItemCache[x] = {
name: ItemDetails.name, type: ItemDetails.type,
price: ItemDetails.price, name: ItemDetails.name,
creator: { price: ItemDetails.price,
name: ItemDetails.creator.name, creator: {
id: ItemDetails.creator.id name: ItemDetails.creator.name,
}, id: ItemDetails.creator.id
thumbnail: ItemDetails.thumbnail, },
asset: undefined thumbnail: ItemDetails.thumbnail,
} asset: undefined
}
if (ItemDetails.type === 'hat') { if (ItemDetails.type === 'hat') {
ItemCache[x].accessoryType = ItemDetails.accessoryType ItemCache[x].accessoryType = ItemDetails.accessoryType
}
} catch(error) {
ItemCache[x] = {
type: "unknown",
name: "#" + x,
price: null,
creator: null,
thumbnail: "https://c0.ptacdn.com/static/images/broken.136e44ee.png",
asset: undefined,
ribbon: "unknown"
}
} }
} }
@ -336,24 +348,36 @@ async function UpdateAvatar() {
const TexturePromise = [Avatar.shirt, Avatar.pants, Avatar.face].filter((x) => x !== undefined && !x.toString().startsWith('http') && !x.toString().startsWith('data:') && x !== undefined).map(async (x, index) => { const TexturePromise = [Avatar.shirt, Avatar.pants, Avatar.face].filter((x) => x !== undefined && !x.toString().startsWith('http') && !x.toString().startsWith('data:') && x !== undefined).map(async (x, index) => {
if (ItemCache[x] === undefined) { if (ItemCache[x] === undefined) {
const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json()) try {
ItemCache[x] = { const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json())
type: ItemDetails.type, ItemCache[x] = {
name: ItemDetails.name, type: ItemDetails.type,
price: ItemDetails.price, name: ItemDetails.name,
creator: { price: ItemDetails.price,
name: ItemDetails.creator.name, creator: {
id: ItemDetails.creator.id name: ItemDetails.creator.name,
}, id: ItemDetails.creator.id
thumbnail: ItemDetails.thumbnail, },
asset: undefined thumbnail: ItemDetails.thumbnail,
} asset: undefined
}
if (ItemDetails.price === 0) { if (ItemDetails.price === 0) {
if (ItemDetails.sales === 0) { if (ItemDetails.sales === 0) {
ItemCache[x].price = null ItemCache[x].price = null
} else { } else {
ItemCache[x].price = 0 ItemCache[x].price = 0
}
}
} catch(error) {
ItemCache[x] = {
type: "unknown",
name: "#" + x,
price: null,
creator: null,
thumbnail: "https://c0.ptacdn.com/static/images/broken.136e44ee.png",
asset: undefined,
ribbon: "unknown"
} }
} }
} }