diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-12-06 10:11:32 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-12-06 10:11:32 -0600 |
commit | 474c4f9b5d38af565069f4b15812082946b07271 (patch) | |
tree | d6a6f9427fe5bfcc75fb91f8c2c84c4f7945faaf /src/state/models/navigation.ts | |
parent | 70cfae56e2ff51e609d5ae6ac6c5a69d11c2a71a (diff) | |
download | voidsky-474c4f9b5d38af565069f4b15812082946b07271.tar.zst |
Rework the 'main menu' to be a screen that's always in history
Diffstat (limited to 'src/state/models/navigation.ts')
-rw-r--r-- | src/state/models/navigation.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/state/models/navigation.ts b/src/state/models/navigation.ts index 6eb13a62a..93aab9d4f 100644 --- a/src/state/models/navigation.ts +++ b/src/state/models/navigation.ts @@ -17,8 +17,11 @@ export type HistoryPtr = [number, number] export class NavigationTabModel { id = genId() - history: HistoryItem[] = [{url: '/', ts: Date.now(), id: genId()}] - index = 0 + history: HistoryItem[] = [ + {url: '/menu', ts: Date.now(), id: genId()}, + {url: '/', ts: Date.now(), id: genId()}, + ] + index = 1 isNewTab = false constructor() { @@ -107,9 +110,15 @@ export class NavigationTabModel { } } - goBackToZero() { - if (this.canGoBack) { - this.index = 0 + resetTo(path: string) { + if (this.index >= 1 && this.history[1]?.url === path) { + // fall back in history to target + if (this.index > 1) { + this.index = 1 + } + } else { + this.history = [this.history[0], {url: path, ts: Date.now(), id: genId()}] + this.index = 1 } } |