From cd2ba91ab93bbd625d86ab211320eb967ea7fbd4 Mon Sep 17 00:00:00 2001 From: Justin Wyne <1986068+wyne@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:47:09 -0700 Subject: [PATCH] Fix game settings page navigation on first create --- src/Navigation.tsx | 2 +- src/components/Buttons/CheckButton.test.tsx | 4 ++-- src/components/Buttons/CheckButton.tsx | 9 ++++----- src/components/Buttons/NewGameButton.tsx | 2 +- src/components/Headers/SettingsHeader.tsx | 2 +- src/components/PopupMenu/AbstractPopupMenu.tsx | 2 +- src/screens/SettingsScreen.tsx | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Navigation.tsx b/src/Navigation.tsx index e31078f8..333cf680 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -31,7 +31,7 @@ export type RootStackParamList = { List: undefined; Game: undefined; Settings: { - reason?: string; + source?: string; }; AppInfo: undefined; Share: undefined; diff --git a/src/components/Buttons/CheckButton.test.tsx b/src/components/Buttons/CheckButton.test.tsx index 48e8946c..93f0d9dd 100644 --- a/src/components/Buttons/CheckButton.test.tsx +++ b/src/components/Buttons/CheckButton.test.tsx @@ -9,7 +9,7 @@ describe('CheckButton', () => { const navigation = useNavigationMock(); it.skip('should navigate to Game screen when pressed', async () => { - const { getByRole } = render(); + const { getByRole } = render(); const button = getByRole('button'); await waitFor(() => { fireEvent.press(button); @@ -18,7 +18,7 @@ describe('CheckButton', () => { }); it.skip('should navigate back a screen when pressed', async () => { - const { getByRole } = render(); + const { getByRole } = render(); const button = getByRole('button'); await waitFor(() => { fireEvent.press(button); diff --git a/src/components/Buttons/CheckButton.tsx b/src/components/Buttons/CheckButton.tsx index b41c3d64..1dc66100 100644 --- a/src/components/Buttons/CheckButton.tsx +++ b/src/components/Buttons/CheckButton.tsx @@ -11,7 +11,7 @@ import HeaderButton from './HeaderButton'; type RouteParams = { Settings: { - reason?: string; + source?: string; }; }; interface Props { @@ -24,11 +24,10 @@ const CheckButton: React.FunctionComponent = ({ navigation, route }) => { return ( { await analytics().logEvent('save_game'); - if (route?.params?.reason === 'new_game') { - navigation.navigate('Game'); + if (route?.params?.source === 'list_screen') { + navigation.navigate('List'); } else { - //TODO: when the game is first created, this will go back instead of to game screen - navigation.goBack(); + navigation.navigate('Game'); } }}> Done diff --git a/src/components/Buttons/NewGameButton.tsx b/src/components/Buttons/NewGameButton.tsx index 84019b11..1aae589f 100644 --- a/src/components/Buttons/NewGameButton.tsx +++ b/src/components/Buttons/NewGameButton.tsx @@ -35,7 +35,7 @@ const NewGameButton: React.FunctionComponent = ({ navigation }) => { }) ).then(() => { setTimeout(() => { - navigation.navigate('Settings', { reason: 'new_game' }); + navigation.navigate('Settings', { source: 'new_game' }); }, 500); }); }; diff --git a/src/components/Headers/SettingsHeader.tsx b/src/components/Headers/SettingsHeader.tsx index 507a18ea..fa5f65a8 100644 --- a/src/components/Headers/SettingsHeader.tsx +++ b/src/components/Headers/SettingsHeader.tsx @@ -10,7 +10,7 @@ import CustomHeader from './CustomHeader'; type RouteParams = { Settings: { - reason?: string; + source?: string; }; }; diff --git a/src/components/PopupMenu/AbstractPopupMenu.tsx b/src/components/PopupMenu/AbstractPopupMenu.tsx index f8e54ff8..7d7279cb 100644 --- a/src/components/PopupMenu/AbstractPopupMenu.tsx +++ b/src/components/PopupMenu/AbstractPopupMenu.tsx @@ -47,7 +47,7 @@ const AbstractPopupMenu: React.FC = (props) => { */ const editGameHandler = async () => { props.setCurrentGameCallback(); - props.navigation.navigate('Settings', { reason: 'edit_game' }); + props.navigation.navigate('Settings', { source: 'list_screen' }); await analytics().logEvent('menu_edit', { round_count: roundTotal, diff --git a/src/screens/SettingsScreen.tsx b/src/screens/SettingsScreen.tsx index 633ed20c..67ece1b0 100644 --- a/src/screens/SettingsScreen.tsx +++ b/src/screens/SettingsScreen.tsx @@ -20,7 +20,7 @@ import logger from '../Logger'; type RouteParams = { Settings: { - reason?: string; + source?: string; }; };