cahce apraisal

This commit is contained in:
2023-09-23 10:56:17 +02:00
parent 1c882e0d1c
commit 14b2f01ef1
3 changed files with 42 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { MarketType, MarketTypePrice, getHistory, getMarketType, getMarketTypes, getPrice, getPrices, jitaId } from "@/market";
import { MarketType, MarketTypePrice, getHistory, getMarketType, getMarketTypes, jitaId, useApraisalStore } from "@/market";
import { ScanResult, ScanResultTable, useMarkeyScanStore } from '@/market/scan';
import { BuyModal } from '@/market/track';
import { ref, watch } from 'vue';
@@ -9,13 +9,14 @@ const buyModal = ref<typeof BuyModal>();
const item = ref("");
const apraisalStore = useApraisalStore();
const markeyScanStore = useMarkeyScanStore();
const items = ref<ScanResult[]>([]);
const addOrRelaod = async (type: MarketType) => {
const typeID = type.id;
const [history, price] = await Promise.all([
getHistory(jitaId, typeID),
getPrice(type)
apraisalStore.getPrice(type)
]);
const item = {
type,
@@ -50,7 +51,7 @@ watch(() => markeyScanStore.types, async t => {
return;
}
const prices = await getPrices(await getMarketTypes(typesToLoad));
const prices = await apraisalStore.getPrices(await getMarketTypes(typesToLoad));
items.value = [...items.value, ...(await Promise.all(typesToLoad.map(async i => {
const price = prices.find(p => p.type.id === i) as MarketTypePrice;

View File

@@ -1,11 +1,13 @@
<script setup lang="ts">
import { MarketTypePrice, getMarketTypes, getPrices } from "@/market";
import { MarketTypePrice, getMarketTypes, useApraisalStore } from "@/market";
import { BuyModal, SellModal, TrackResultTable, TrackedItem, useTrackedItemStore } from '@/market/track';
import { ref, watch } from 'vue';
const buyModal = ref<typeof BuyModal>();
const sellModal = ref<typeof SellModal>();
const apraisalStore = useApraisalStore();
const trackedItemStore = useTrackedItemStore();
const items = ref<TrackedItem[]>([]);
@@ -14,7 +16,7 @@ watch(() => trackedItemStore.items.value, async itms => {
return;
}
const prices = await getPrices(await getMarketTypes(itms.map(i => i.typeID)));
const prices = await apraisalStore.getPrices(await getMarketTypes(itms.map(i => i.typeID)));
items.value = itms.map(i => {
const price = prices.find(p => p.type.id === i.typeID) as MarketTypePrice;