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,6 +292,7 @@ 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) {
try {
const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json()) const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json())
ItemCache[x] = { ItemCache[x] = {
type: ItemDetails.type, type: ItemDetails.type,
@ -308,6 +309,17 @@ async function UpdateAvatar() {
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"
}
}
} }
if (ItemCache[x].asset === undefined) { if (ItemCache[x].asset === undefined) {
@ -336,6 +348,7 @@ 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) {
try {
const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json()) const ItemDetails = (await (await fetch('https://api.polytoria.com/v1/store/' + x)).json())
ItemCache[x] = { ItemCache[x] = {
type: ItemDetails.type, type: ItemDetails.type,
@ -356,6 +369,17 @@ async function UpdateAvatar() {
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"
}
}
} }
if (ItemCache[x].asset === undefined) { if (ItemCache[x].asset === undefined) {