From eccbd66c1836155a4cfb6ada10cb10c641f16fec Mon Sep 17 00:00:00 2001 From: Austin Warren Date: Wed, 17 Jul 2019 17:15:14 -0700 Subject: [PATCH] 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 --- terminus-core/src/services/app.service.ts | 36 +++++++++++++---------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/terminus-core/src/services/app.service.ts b/terminus-core/src/services/app.service.ts index 69d18325..e32422f1 100644 --- a/terminus-core/src/services/app.service.ts +++ b/terminus-core/src/services/app.service.ts @@ -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); } }