You've already forked tf2wikipricing
refactor: fetchPrice now expects an SKU string
This commit is contained in:
@@ -206,7 +206,7 @@ async function inject() {
|
||||
|
||||
var data: ItemPriceData | null
|
||||
try {
|
||||
data = await fetchPrice(token, itemIndex, quality, currentTime);
|
||||
data = await fetchPrice(token, itemIndex + ";" + quality, currentTime);
|
||||
updateTime = new Date(data.update)
|
||||
} catch {
|
||||
log(`${qualifiedName} is unpriced or unavailable, skipping...`)
|
||||
|
||||
@@ -30,7 +30,7 @@ export class ItemPriceData {
|
||||
|
||||
|
||||
export async function fetchKeyPrice(token: string) {
|
||||
return fetchPrice(token, defindex_key, 6, new Date(), 86400000)
|
||||
return fetchPrice(token, `${defindex_key};6`, new Date(), 86400000)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,9 +39,8 @@ export async function fetchKeyPrice(token: string) {
|
||||
* @param update Date retrieved.
|
||||
* @param ttl Time to cache results in milliseconds. 30 minutes by default.
|
||||
*/
|
||||
export async function fetchPrice(token: string, defIndex: number, quality: number, update: Date = new Date(), ttl: number = 30 * 60 * 1000): Promise<ItemPriceData> {
|
||||
export async function fetchPrice(token: string, sku: string, update: Date = new Date(), ttl: number = 30 * 60 * 1000): Promise<ItemPriceData> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const sku = defIndex.toString() + ";" + quality.toString();
|
||||
var data: ItemPriceData | null
|
||||
|
||||
const cached = await getStorageValue(storage_priceprefix + sku, null)
|
||||
|
||||
Reference in New Issue
Block a user