diff --git a/composables/downloads.ts b/composables/downloads.ts index 860a8c3..55de7fb 100644 --- a/composables/downloads.ts +++ b/composables/downloads.ts @@ -1,7 +1,8 @@ import { listen } from "@tauri-apps/api/event"; +import type { DownloadableMetadata } from "~/types"; export type QueueState = { - queue: Array<{ id: string; status: string; progress: number | null }>; + queue: Array<{ meta: DownloadableMetadata; status: string; progress: number | null }>; status: string; }; @@ -24,4 +25,4 @@ listen("update_queue", (event) => { listen("update_stats", (event) => { const stats = useStatsState(); stats.value = event.payload as StatsState; -}); +}); \ No newline at end of file diff --git a/composables/game.ts b/composables/game.ts index c2ffc0c..0335a7a 100644 --- a/composables/game.ts +++ b/composables/game.ts @@ -13,6 +13,7 @@ export type SerializedGameStatus = [ ]; export const parseStatus = (status: SerializedGameStatus): GameStatus => { + console.log(status); if (status[0]) { return { type: status[0].type, @@ -28,28 +29,29 @@ export const parseStatus = (status: SerializedGameStatus): GameStatus => { } }; -export const useGame = async (id: string) => { - if (!gameRegistry[id]) { +export const useGame = async (gameId: string) => { + if (!gameRegistry[gameId]) { const data: { game: Game; status: SerializedGameStatus } = await invoke( "fetch_game", { - id, + gameId, } ); - gameRegistry[id] = data.game; - if (!gameStatusRegistry[id]) { - gameStatusRegistry[id] = ref(parseStatus(data.status)); + gameRegistry[gameId] = data.game; + if (!gameStatusRegistry[gameId]) { + gameStatusRegistry[gameId] = ref(parseStatus(data.status)); - listen(`update_game/${id}`, (event) => { + listen(`update_game/${gameId}`, (event) => { const payload: { status: SerializedGameStatus; } = event.payload as any; - gameStatusRegistry[id].value = parseStatus(payload.status); + console.log(payload.status); + gameStatusRegistry[gameId].value = parseStatus(payload.status); }); } } - const game = gameRegistry[id]; - const status = gameStatusRegistry[id]; + const game = gameRegistry[gameId]; + const status = gameStatusRegistry[gameId]; return { game, status }; -}; +}; \ No newline at end of file diff --git a/pages/queue.vue b/pages/queue.vue index 52574dd..d78967c 100644 --- a/pages/queue.vue +++ b/pages/queue.vue @@ -14,19 +14,19 @@