diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Navigation.tsx | 11 | ||||
-rw-r--r-- | src/lib/routes/helpers.ts | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 87330e3bf..77e7cfa0b 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -410,7 +410,16 @@ const LINKING = { if (name === 'Notifications') { return buildStateObject('NotificationsTab', 'Notifications', params) } - return buildStateObject('HomeTab', name, params) + if (name === 'Home') { + return buildStateObject('HomeTab', 'Home', params) + } + // if the path is something else, like a post, profile, or even settings, we need to initialize the home tab as pre-existing state otherwise the back button will not work + return buildStateObject('HomeTab', name, params, [ + { + name: 'Home', + params: {}, + }, + ]) } else { return buildStateObject('Flat', name, params) } diff --git a/src/lib/routes/helpers.ts b/src/lib/routes/helpers.ts index 071e1ae9b..8aef5b83a 100644 --- a/src/lib/routes/helpers.ts +++ b/src/lib/routes/helpers.ts @@ -55,10 +55,15 @@ export function getTabState(state: State | undefined, tab: string): TabState { return TabState.Outside } +type ExistingState = { + name: string + params?: RouteParams +} export function buildStateObject( stack: string, route: string, params: RouteParams, + state: ExistingState[] = [], ) { if (stack === 'Flat') { return { @@ -70,7 +75,7 @@ export function buildStateObject( { name: stack, state: { - routes: [{name: route, params}], + routes: [...state, {name: route, params}], }, }, ], |