1
0
mirror of https://github.com/Eugeny/tabby.git synced 2025-08-23 17:51:50 +00:00

Alter tab recovery system to only keep track of tabs in main window. Also fix issue where closing main window would remove all tabs from saved tab state

This commit is contained in:
Austin Warren
2019-07-17 17:15:14 -07:00
parent 041a2a92d5
commit eccbd66c18

@@ -1,8 +1,11 @@
import { Observable, Subject, AsyncSubject } from 'rxjs' import { Observable, Subject, AsyncSubject } from 'rxjs'
import { takeUntil } from 'rxjs/operators' import { takeUntil } from 'rxjs/operators'
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { BaseTabComponent } from '../components/baseTab.component' import { BaseTabComponent } from '../components/baseTab.component'
import { SplitTabComponent } from '../components/splitTab.component' import { SplitTabComponent } from '../components/splitTab.component'
import { ConfigService } from './config.service' import { ConfigService } from './config.service'
import { HostAppService } from './hostApp.service' import { HostAppService } from './hostApp.service'
import { TabRecoveryService } from './tabRecovery.service' import { TabRecoveryService } from './tabRecovery.service'
@@ -67,11 +70,11 @@ export class AppService {
private tabRecovery: TabRecoveryService, private tabRecovery: TabRecoveryService,
private tabsService: TabsService, private tabsService: TabsService,
) { ) {
if (hostApp.getWindow().id === 1) {
this.tabRecovery.recoverTabs().then(tabs => { this.tabRecovery.recoverTabs().then(tabs => {
for (const tab of tabs) { for (const tab of tabs) {
this.openNewTabRaw(tab.type, tab.options) this.openNewTabRaw(tab.type, tab.options)
} }
this.tabsChanged$.subscribe(() => { this.tabsChanged$.subscribe(() => {
tabRecovery.saveTabs(this.tabs) tabRecovery.saveTabs(this.tabs)
}) })
@@ -80,6 +83,7 @@ export class AppService {
}, 30000) }, 30000)
}) })
} }
}
addTabRaw (tab: BaseTabComponent) { addTabRaw (tab: BaseTabComponent) {
this.tabs.push(tab) this.tabs.push(tab)
@@ -87,9 +91,11 @@ export class AppService {
this.tabsChanged.next() this.tabsChanged.next()
this.tabOpened.next(tab) this.tabOpened.next(tab)
if (this.hostApp.getWindow().id === 1) {
tab.recoveryStateChangedHint$.subscribe(() => { tab.recoveryStateChangedHint$.subscribe(() => {
this.tabRecovery.saveTabs(this.tabs) this.tabRecovery.saveTabs(this.tabs)
}) })
}
tab.titleChange$.subscribe(title => { tab.titleChange$.subscribe(title => {
if (tab === this._activeTab) { if (tab === this._activeTab) {
@@ -213,7 +219,7 @@ export class AppService {
} }
} }
for (const tab of this.tabs) { for (const tab of this.tabs) {
tab.destroy() tab.destroy(true);
} }
} }