From af263d6eafe4fb60c4eb8524c905a2dc8f7c2122 Mon Sep 17 00:00:00 2001 From: Justin Wyne <1986068+wyne@users.noreply.github.com> Date: Thu, 18 Jul 2024 18:21:47 -0700 Subject: [PATCH 1/2] Fix bug with initial game state --- redux/GamesSlice.ts | 12 +++++++----- redux/store.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/redux/GamesSlice.ts b/redux/GamesSlice.ts index 4cc348bc..9e2218da 100644 --- a/redux/GamesSlice.ts +++ b/redux/GamesSlice.ts @@ -29,13 +29,16 @@ const gamesAdapter = createEntityAdapter({ }); const initialState = gamesAdapter.getInitialState({ +}); + +const gameDefaults = { roundCurrent: 0, roundTotal: 1, locked: false, sortSelectorKey: SortSelectorKey.ByScore, sortDirectionKey: SortDirectionKey.Normal, palette: 'original', -}); +}; const gamesSlice = createSlice({ name: 'games', @@ -143,11 +146,10 @@ export const asyncRematchGame = createAsyncThunk( }); dispatch(gameSave({ + ...gameDefaults, id: newGameId, title: game.title, dateCreated: Date.now(), - roundCurrent: 0, - roundTotal: 1, playerIds: playerIds, })); @@ -203,7 +205,7 @@ export const asyncCreateGame = createAsyncThunk( playerIds.push(Crypto.randomUUID()); } - const paletteName = initialState.palette; + const paletteName = gameDefaults.palette; const paletteColors = getPalette(paletteName); playerIds.forEach((playerId, index) => { @@ -217,7 +219,7 @@ export const asyncCreateGame = createAsyncThunk( }); dispatch(gameSave({ - ...initialState, + ...gameDefaults, id: newGameId, title: `Game ${gameCount + 1}`, dateCreated: Date.now(), diff --git a/redux/store.ts b/redux/store.ts index 951d3d70..d466c85e 100644 --- a/redux/store.ts +++ b/redux/store.ts @@ -31,7 +31,7 @@ const gamesPersistConfig = { key: 'games', version: 0, storage: AsyncStorage, - whitelist: ['entities', 'ids', 'sortSelectorKey'], + whitelist: ['entities', 'ids'], }; const playersPersistConfig = { From e3bbdd1c3e5bd04fa5808bb735ef27a55c2353fe Mon Sep 17 00:00:00 2001 From: Justin Wyne <1986068+wyne@users.noreply.github.com> Date: Thu, 18 Jul 2024 18:24:02 -0700 Subject: [PATCH 2/2] Add github action to run tsc --- .github/workflows/node.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 2a5baa81..bd98137a 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -27,5 +27,5 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm ci - - run: npx eslint . + - run: npm run lint - run: npm test