This commit is contained in:
2023-11-16 11:26:17 +01:00
parent 98ce81dfb2
commit a1bffa1cdb
8 changed files with 73 additions and 17 deletions
+6 -1
View File
@@ -3,6 +3,7 @@ import { ref } from 'vue';
import { MarketType } from "../type";
import { MarketTypePrice } from './MarketTypePrice';
import { getEvepraisalPrices } from './evepraisal';
import { getfuzzworkPrices } from './fuzzwork';
type MarketTypePriceCache = {
price: MarketTypePrice,
@@ -10,11 +11,15 @@ type MarketTypePriceCache = {
}
const cacheDuration = 1000 * 60 * 5; // 5 minutes
const priceGetters = {
evepraisal: getEvepraisalPrices,
fuzzwork: getfuzzworkPrices
}
export const useApraisalStore = defineStore('appraisal', () => {
const cache = ref<Record<number, MarketTypePriceCache>>({});
const getPricesUncached = getEvepraisalPrices;
const getPricesUncached = priceGetters.fuzzwork;
const getPrice = async (type: MarketType): Promise<MarketTypePrice> => (await getPrices([type]))[0];
const getPrices = async (types: MarketType[]): Promise<MarketTypePrice[]> => {