diff --git a/src/lib/components/inventory/list_item_modal_styles.ts b/src/lib/components/inventory/list_item_modal_styles.ts index 60e29fe..0faf280 100644 --- a/src/lib/components/inventory/list_item_modal_styles.ts +++ b/src/lib/components/inventory/list_item_modal_styles.ts @@ -92,6 +92,7 @@ export const listItemModalStyles = [ .modal-content { background: rgba(21, 23, 28, 0.8); + backdrop-filter: blur(16px) padding: 20px; width: 500px; max-width: 90%; diff --git a/src/lib/services/price_fetcher.ts b/src/lib/services/price_fetcher.ts index 31d436a..5cd4d88 100644 --- a/src/lib/services/price_fetcher.ts +++ b/src/lib/services/price_fetcher.ts @@ -16,24 +16,24 @@ interface DopplerPriceListResponse { } interface PriceCache { - timestamp: number; + lastUpdated: number; prices: Record; dopplerPrices: Record>; } class PriceFetcher { - async fetch(market_hash_name: string, paintIndex?: number): Promise { + async fetch(marketHashName: string, paintIndex?: number): Promise { const {prices, dopplerPrices} = await this.getValidPrices(); // If it's a Doppler and we have a paint index, use the Doppler price if (paintIndex !== undefined) { - const dopplerPrice = dopplerPrices[market_hash_name]?.[paintIndex]; + const dopplerPrice = dopplerPrices[marketHashName]?.[paintIndex]; if (dopplerPrice) { return dopplerPrice; } } - return prices[market_hash_name] || 0; + return prices[marketHashName] || 0; } private async getValidPrices(): Promise<{ @@ -44,7 +44,7 @@ class PriceFetcher { // Try loading from storage first const storedCache = await gStore.getWithStorage(chrome.storage.local, PRICE_CACHE.key); - if (storedCache && now - storedCache.timestamp < DEFAULT_CACHE_DURATION) { + if (storedCache && now - storedCache.lastUpdated < DEFAULT_CACHE_DURATION) { return { prices: storedCache.prices, dopplerPrices: storedCache.dopplerPrices || {}, @@ -89,17 +89,22 @@ class PriceFetcher { } await gStore.setWithStorage(chrome.storage.local, PRICE_CACHE.key, { - timestamp: now, + lastUpdated: now, prices, dopplerPrices, }); return {prices, dopplerPrices}; } catch (error) { - // On error, return existing cache regardless of age, or empty objects if no cache exists + // If we have no stored cache, bubble up the error + if (!storedCache) { + throw new Error('Failed to fetch prices and no cached data available'); + } + + // On error with existing cache, return existing cache regardless of age return { - prices: storedCache?.prices || {}, - dopplerPrices: storedCache?.dopplerPrices || {}, + prices: storedCache.prices || {}, + dopplerPrices: storedCache.dopplerPrices || {}, }; } } diff --git a/src/lib/storage/keys.ts b/src/lib/storage/keys.ts index 3a4b0bf..9a57e3e 100644 --- a/src/lib/storage/keys.ts +++ b/src/lib/storage/keys.ts @@ -49,4 +49,8 @@ export const PAGE_SIZE = newRow(StorageKey.PAGE_SIZE); // Dynamic prefixes should be the market hash name of the item export const DYNAMIC_ITEM_FILTERS = newDynamicRow(StorageKey.ITEM_FILTERS); export const GLOBAL_FILTERS = newRow(StorageKey.GLOBAL_FILTERS); -export const PRICE_CACHE = newRow<{timestamp: number; prices: Record}>(StorageKey.PRICE_CACHE); +export const PRICE_CACHE = newRow<{ + lastUpdated: number; + prices: Record; + dopplerPrices?: Record>; +}>(StorageKey.PRICE_CACHE);