Skip to content

Commit f12284c

Browse files
committed
Price fetcher nits. Backdrop blur on modal content. Update price fetcher types in keys
1 parent ac10a7f commit f12284c

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/lib/components/inventory/list_item_modal_styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const listItemModalStyles = [
9292
9393
.modal-content {
9494
background: rgba(21, 23, 28, 0.8);
95+
backdrop-filter: blur(16px);
9596
padding: 20px;
9697
width: 500px;
9798
max-width: 90%;

src/lib/services/price_fetcher.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ interface DopplerPriceListResponse {
1616
}
1717

1818
interface PriceCache {
19-
timestamp: number;
19+
lastUpdated: number;
2020
prices: Record<string, number>;
2121
dopplerPrices: Record<string, Record<number, number>>;
2222
}
2323

2424
class PriceFetcher {
25-
async fetch(market_hash_name: string, paintIndex?: number): Promise<number> {
25+
async fetch(marketHashName: string, paintIndex?: number): Promise<number> {
2626
const {prices, dopplerPrices} = await this.getValidPrices();
2727

2828
// If it's a Doppler and we have a paint index, use the Doppler price
2929
if (paintIndex !== undefined) {
30-
const dopplerPrice = dopplerPrices[market_hash_name]?.[paintIndex];
30+
const dopplerPrice = dopplerPrices[marketHashName]?.[paintIndex];
3131
if (dopplerPrice) {
3232
return dopplerPrice;
3333
}
3434
}
3535

36-
return prices[market_hash_name] || 0;
36+
return prices[marketHashName] || 0;
3737
}
3838

3939
private async getValidPrices(): Promise<{
@@ -44,7 +44,7 @@ class PriceFetcher {
4444

4545
// Try loading from storage first
4646
const storedCache = await gStore.getWithStorage<PriceCache>(chrome.storage.local, PRICE_CACHE.key);
47-
if (storedCache && now - storedCache.timestamp < DEFAULT_CACHE_DURATION) {
47+
if (storedCache && now - storedCache.lastUpdated < DEFAULT_CACHE_DURATION) {
4848
return {
4949
prices: storedCache.prices,
5050
dopplerPrices: storedCache.dopplerPrices || {},
@@ -89,17 +89,22 @@ class PriceFetcher {
8989
}
9090

9191
await gStore.setWithStorage(chrome.storage.local, PRICE_CACHE.key, {
92-
timestamp: now,
92+
lastUpdated: now,
9393
prices,
9494
dopplerPrices,
9595
});
9696

9797
return {prices, dopplerPrices};
9898
} catch (error) {
99-
// On error, return existing cache regardless of age, or empty objects if no cache exists
99+
// If we have no stored cache, bubble up the error
100+
if (!storedCache) {
101+
throw new Error('Failed to fetch prices and no cached data available');
102+
}
103+
104+
// On error with existing cache, return existing cache regardless of age
100105
return {
101-
prices: storedCache?.prices || {},
102-
dopplerPrices: storedCache?.dopplerPrices || {},
106+
prices: storedCache.prices || {},
107+
dopplerPrices: storedCache.dopplerPrices || {},
103108
};
104109
}
105110
}

src/lib/storage/keys.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,8 @@ export const PAGE_SIZE = newRow<number>(StorageKey.PAGE_SIZE);
4949
// Dynamic prefixes should be the market hash name of the item
5050
export const DYNAMIC_ITEM_FILTERS = newDynamicRow<SerializedFilter[]>(StorageKey.ITEM_FILTERS);
5151
export const GLOBAL_FILTERS = newRow<SerializedFilter[]>(StorageKey.GLOBAL_FILTERS);
52-
export const PRICE_CACHE = newRow<{timestamp: number; prices: Record<string, number>}>(StorageKey.PRICE_CACHE);
52+
export const PRICE_CACHE = newRow<{
53+
lastUpdated: number;
54+
prices: Record<string, number>;
55+
dopplerPrices?: Record<string, Record<number, number>>;
56+
}>(StorageKey.PRICE_CACHE);

0 commit comments

Comments
 (0)