From 0e5a3d75e3cb7a2afc935036c351ca165c89ca60 Mon Sep 17 00:00:00 2001 From: Index Date: Fri, 28 Jun 2024 11:52:35 -0500 Subject: [PATCH] fix: store owned tag inventory caching --- js/store/store.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/js/store/store.js b/js/store/store.js index 9c40f9f..f348da2 100755 --- a/js/store/store.js +++ b/js/store/store.js @@ -28,9 +28,9 @@ chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) { if (Settings.StoreOwnTagOn === true) { chrome.storage.local.get('PolyPlus_InventoryCache', async function(result){ console.log(result) - if (result.PolyPlus_InventoryCache !== undefined && (new Date().getTime() - result.PolyPlus_InventoryCache[1] < 5000)) { + if (result.PolyPlus_InventoryCache !== undefined && (new Date().getTime() - result.PolyPlus_InventoryCache.requested < 30000)) { console.log('not undefined') - Inventory = result.PolyPlus_InventoryCache[0] + Inventory = result.PolyPlus_InventoryCache.data Array.from(ItemGrid.children).forEach((element) => { LoadOwnedTags(element); }); @@ -41,8 +41,7 @@ chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) { Inventory = [...Inventory, ...(await (await fetch('https://api.polytoria.com/v1/users/' + UserID + '/inventory?type=face&limit=100')).json()).inventory]; Inventory = [...Inventory, ...(await (await fetch('https://api.polytoria.com/v1/users/' + UserID + '/inventory?type=tool&limit=100')).json()).inventory]; Inventory = [...Inventory, ...(await (await fetch('https://api.polytoria.com/v1/users/' + UserID + '/inventory?type=profileTheme&limit=100')).json()).inventory]; - console.log(Inventory); - chrome.storage.local.set({'PolyPlus_InventoryCache': [Inventory, new Date().getTime()]}, function(){}) + chrome.storage.local.set({'PolyPlus_InventoryCache': {data: Inventory, requested: new Date().getTime()}}, function(){}) Array.from(ItemGrid.children).forEach((element) => { LoadOwnedTags(element); });