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

View File

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