type info
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { MarketOrderHistory, MarketType } from "@/market";
|
||||
import { MarketOrderHistory, MarketType, MarketTypePrice, getHistory, jitaId } from "@/market";
|
||||
import { usePocketBase, watchCollection } from "@/pocketbase";
|
||||
import { defineStore } from "pinia";
|
||||
import { RecordModel } from "pocketbase";
|
||||
@@ -31,6 +31,16 @@ export const useMarketScanStore = defineStore(marketScans, () => {
|
||||
marketScan.value = await pb.collection(marketScans).create({ owner: pb.authStore.model!.id, types });
|
||||
}
|
||||
}
|
||||
const addType = async (type: number) => {
|
||||
if (!types.value.includes(type)) {
|
||||
await setTypes([...types.value, type]);
|
||||
}
|
||||
}
|
||||
const removeType = async (type: number) => {
|
||||
if (types.value.includes(type)) {
|
||||
await setTypes(types.value.filter(t => t !== type));
|
||||
}
|
||||
}
|
||||
|
||||
watchCollection<MarketScan>(marketScans, '*', data => {
|
||||
if (data.action === 'delete') {
|
||||
@@ -40,5 +50,7 @@ export const useMarketScanStore = defineStore(marketScans, () => {
|
||||
}
|
||||
});
|
||||
onMounted(async () => marketScan.value = await pb.collection(marketScans).getFirstListItem<MarketScan>('').catch(() => undefined));
|
||||
return { types, setTypes };
|
||||
});
|
||||
return { types, setTypes, addType, removeType };
|
||||
});
|
||||
|
||||
export const createResult = async (id: number, price: MarketTypePrice): Promise<ScanResult> => ({ history: await getHistory(jitaId, id), ...price });
|
||||
Reference in New Issue
Block a user