From 74c6b6f68851d83d8061e1227f07b4c46bc1f9c1 Mon Sep 17 00:00:00 2001 From: Neshura Date: Tue, 15 Aug 2023 22:51:41 +0200 Subject: [PATCH] Start of dynamic ethic fetching --- src/lib/stores/ChellarisData.ts | 6 +++++- src/routes/graphs/+layout.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/stores/ChellarisData.ts b/src/lib/stores/ChellarisData.ts index 0729c9b..5b8c659 100644 --- a/src/lib/stores/ChellarisData.ts +++ b/src/lib/stores/ChellarisData.ts @@ -1,6 +1,10 @@ import { writable, type Writable } from "svelte/store"; import type { ChellarisInfo } from '../types/chellaris'; -const ChellarisDataStore: Writable = writable(); +const ChellarisDataStore: Writable = writable({ + games: new Map(), + ethics: [], + portraits: [] +}); export default ChellarisDataStore; \ No newline at end of file diff --git a/src/routes/graphs/+layout.ts b/src/routes/graphs/+layout.ts index aa99842..91c195d 100644 --- a/src/routes/graphs/+layout.ts +++ b/src/routes/graphs/+layout.ts @@ -54,11 +54,15 @@ export const load: LayoutLoad = async () => { } }); - console.log(chellarisData); //DEBUG + const ethics: {id: number, name: string, fanatic: boolean}[] = await (await fetch(apiBaseUrl + '/ethics')).json(); + + ethics.forEach(ethic => { + console.log(ethic.name); + }); + ChellarisDataStore.set(chellarisData); // Local Storage Code - if (typeof localStorage !== 'undefined') { // Tab Selection store = localStorage.getItem('graphsTab');