From d608d67bfee9e5f31a85e8d2add52d6ffa6e5309 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 22 Nov 2022 12:19:38 -0600 Subject: Turn home button into a 'go back to start of nav history' --- src/state/models/navigation.ts | 6 ++++++ src/view/shell/mobile/index.tsx | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/state/models/navigation.ts b/src/state/models/navigation.ts index 1e639b0f3..6eb13a62a 100644 --- a/src/state/models/navigation.ts +++ b/src/state/models/navigation.ts @@ -107,6 +107,12 @@ export class NavigationTabModel { } } + goBackToZero() { + if (this.canGoBack) { + this.index = 0 + } + } + goForward() { if (this.canGoForward) { this.index++ diff --git a/src/view/shell/mobile/index.tsx b/src/view/shell/mobile/index.tsx index 9e2d92076..8ea79b92b 100644 --- a/src/view/shell/mobile/index.tsx +++ b/src/view/shell/mobile/index.tsx @@ -134,7 +134,7 @@ export const MobileShell: React.FC = observer(() => { if (store.nav.tab.current.url === '/') { scrollElRef.current?.scrollToOffset({offset: 0}) } else { - store.nav.navigate('/') + store.nav.tab.goBackToZero() } } const onPressMenu = () => setMainMenuActive(true) -- cgit 1.4.1