Merge branch 'simplify' into main

This commit is contained in:
Paul Frazee 2022-11-21 18:55:08 -06:00
commit e858bb52de
20 changed files with 180 additions and 232 deletions

View file

@ -1,5 +1,5 @@
import {makeAutoObservable} from 'mobx'
import {isObj, hasProp} from '../lib/type-guards'
import {TABS_ENABLED} from '../../build-flags'
let __id = 0
function genId() {
@ -244,6 +244,9 @@ export class NavigationModel {
// =
newTab(url: string, title?: string) {
if (!TABS_ENABLED) {
return this.navigate(url)
}
const tab = new NavigationTabModel()
tab.navigate(url, title)
tab.isNewTab = true
@ -252,10 +255,16 @@ export class NavigationModel {
}
setActiveTab(tabIndex: number) {
if (!TABS_ENABLED) {
return
}
this.tabIndex = Math.max(Math.min(tabIndex, this.tabs.length - 1), 0)
}
closeTab(tabIndex: number) {
if (!TABS_ENABLED) {
return
}
this.tabs = [
...this.tabs.slice(0, tabIndex),
...this.tabs.slice(tabIndex + 1),