diff options
Diffstat (limited to 'src/state')
-rw-r--r-- | src/state/models/navigation.ts | 19 | ||||
-rw-r--r-- | src/state/models/session.ts | 5 |
2 files changed, 18 insertions, 6 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 } } diff --git a/src/state/models/session.ts b/src/state/models/session.ts index 069e3db32..1537d1316 100644 --- a/src/state/models/session.ts +++ b/src/state/models/session.ts @@ -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 } |