From d5c84e9b6347db6e0f90e0b1125a1b197d4e1f0e Mon Sep 17 00:00:00 2001 From: Jakob Ankarhem Date: Sat, 26 Mar 2022 10:59:07 +0100 Subject: [PATCH] feat: Add suspend with loading indicator Fixes an issue where bad internet connection could introduce faulty gamestates due to race-condition --- src/components/Board.svelte | 13 ++++- src/components/Keyboard/Key.svelte | 4 +- src/components/Keyboard/Keyboard.svelte | 9 ++- src/components/LoadingSpinner.svelte | 76 ++++++++++++++----------- src/components/store.ts | 2 + 5 files changed, 66 insertions(+), 38 deletions(-) diff --git a/src/components/Board.svelte b/src/components/Board.svelte index 37a0b5f..fa0fbac 100644 --- a/src/components/Board.svelte +++ b/src/components/Board.svelte @@ -1,5 +1,7 @@ -
-
-
-
-
+
+
+ + + +
diff --git a/src/components/store.ts b/src/components/store.ts index ae72ce4..a6bc359 100644 --- a/src/components/store.ts +++ b/src/components/store.ts @@ -13,6 +13,7 @@ const createEmptyGrid = (): TileType[][] => { export const createInitialGameState = (wordId?: number): GameData => { const gameState: GameData = { + loading: false, grid: createEmptyGrid(), currentRow: 0, state: GameState.Playing, @@ -24,6 +25,7 @@ export const createInitialGameState = (wordId?: number): GameData => { }; interface GameData { + loading: boolean; grid: TileType[][]; currentRow: number; state: GameState;