Improved? Data loading

This commit is contained in:
Neshura 2023-08-15 22:51:13 +02:00
parent 56a73adbfe
commit 716fc71282
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
2 changed files with 9 additions and 5 deletions

View file

@ -1,14 +1,15 @@
import type { PageLoad } from "../$types";
import ChellarisDataStore from '$lib/stores/ChellarisData';
import SelectedGameStore from '$lib/stores/GameFilter';
import { type ChellarisInfo, type ChellarisGame, type ChellarisGameGroup, createChellarisInfo, createChellarisGameGroup, createChellarisGame, createChellarisEmpire } from '../../lib/types/chellaris';
import SelectedGameGroupsStore from "$lib/stores/GameGroupFilter";
import GraphsTabStore from '$lib/stores/GraphsTab';
import { createChellarisInfo, type ChellarisGame, createChellarisGame, createChellarisGameGroup, createChellarisEmpire } from "$lib/types/chellaris";
import type { LayoutLoad } from "./$types";
export const load: PageLoad = async () => {
export const load: LayoutLoad = async () => {
let store: string | null;
const apiBaseUrl = 'https://www.chellaris.net/api/v2';
const chellarisData = createChellarisInfo();
let store: string | null;
// Chellaris Data Code
const games: {id: number, name: string}[] = await (await fetch(apiBaseUrl + '/games')).json();
@ -97,4 +98,5 @@ export const load: PageLoad = async () => {
SelectedGameGroupsStore.set(gameGroupSelectionMap);
}
}
return { chellarisData }
}

View file

@ -11,11 +11,13 @@
} from '$lib/types/chellaris';
import ChellarisDataStore from '$lib/stores/ChellarisData';
import GraphsTabStore from '$lib/stores/GraphsTab';
import type { LayoutData } from '../$types';
export let data: LayoutData;
let selectedGameGroups: Array<number> = [];
let selectedGameGroupsMap: Map<number, Array<number>> = new Map();
let gameGroups: Map<number, ChellarisGameGroup> = new Map();
let chellarisData: ChellarisInfo = createChellarisInfo();
let chellarisData: ChellarisInfo = data.chellarisData;
let selectedGameIdx: number;
let selectedGame: ChellarisGame = createChellarisGame();;
let pageData: {