Rework the 'main menu' to be a screen that's always in history
This commit is contained in:
parent
70cfae56e2
commit
474c4f9b5d
7 changed files with 300 additions and 379 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,10 @@ export class SessionModel {
|
|||
}
|
||||
|
||||
async connect(): Promise<void> {
|
||||
this._connectPromise ??= this._connect()
|
||||
if (this._connectPromise) {
|
||||
return this._connectPromise
|
||||
}
|
||||
this._connectPromise = this._connect()
|
||||
await this._connectPromise
|
||||
this._connectPromise = undefined
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue