feat: add currency conversions to price table

Exchange rates are loaded once per page and passed to price row generation, so we don't hit the cache more than once.
This commit is contained in:
xenticore
2025-04-16 18:24:27 -04:00
parent fcf077c877
commit 1d92d9e20c
3 changed files with 12 additions and 10 deletions

View File

@@ -222,7 +222,7 @@ async function inject() {
}
const qualityName = itemQualities[quality as unknown as keyof typeof itemQualities].toString()
const priceRow = createPriceRow(qualityName, data, keyPrice, locale)
const priceRow = createPriceRow(qualityName, data, keyPrice, exchangeRates, locale)
priceRows.push({order: quality == 6 ? -1 : quality, row: priceRow, category: PriceRowCategory.None})
})
@@ -239,7 +239,7 @@ async function inject() {
log(`Australium ${itemName} is unpriced or unavailable, skipping...`)
}
const priceRow = createPriceRow($T("Australium"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Australium_weapons")
const priceRow = createPriceRow($T("Australium"), data, keyPrice, exchangeRates, locale, "https://wiki.teamfortress.com/wiki/Australium_weapons")
priceRows.push({order: 99, row: priceRow, category: PriceRowCategory.None})
resolve()
@@ -271,7 +271,7 @@ async function inject() {
log(`Festive ${itemName} is unpriced or unavailable, skipping...`)
}
const priceRow = createPriceRow($T("Unique"), data, keyPrice, locale)
const priceRow = createPriceRow($T("Unique"), data, keyPrice, exchangeRates, locale)
priceRows.push({order: -1, row: priceRow, category: PriceRowCategory.Festive})
resolve()
@@ -287,7 +287,7 @@ async function inject() {
log(`Strange Festive ${itemName} is unpriced or unavailable, skipping...`)
}
const priceRow = createPriceRow($T("Strange"), data, keyPrice, locale)
const priceRow = createPriceRow($T("Strange"), data, keyPrice, exchangeRates, locale)
priceRows.push({order: 11, row: priceRow, category: PriceRowCategory.Festive})
resolve()
@@ -331,7 +331,7 @@ async function inject() {
return
}
const priceRow = createPriceRow($T(`kt-${tier}`), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Killstreak_Kit")
const priceRow = createPriceRow($T(`kt-${tier}`), data, keyPrice, exchangeRates, locale, "https://wiki.teamfortress.com/wiki/Killstreak_Kit")
priceRows.push({order: tier, row: priceRow, category: PriceRowCategory.KillstreakKit})
resolve()
@@ -378,7 +378,7 @@ async function inject() {
log(`${itemName} is unpriced or unavailable, skipping...`)
}
const priceRow = createPriceRow($T(variantName), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Botkiller_weapons")
const priceRow = createPriceRow($T(variantName), data, keyPrice, exchangeRates, locale, "https://wiki.teamfortress.com/wiki/Botkiller_weapons")
// FIXME: order should be by release
// Silver Mk.I, Gold Mk.II, Rust, Blood, Carbonado, Diamond, Silver Mk.II, Gold Mk.II