diff --git a/tabby-core/src/services/app.service.ts b/tabby-core/src/services/app.service.ts index 28667a23..98071aea 100644 --- a/tabby-core/src/services/app.service.ts +++ b/tabby-core/src/services/app.service.ts @@ -1,4 +1,4 @@ -import { Observable, Subject, AsyncSubject, takeUntil } from 'rxjs' +import { Observable, Subject, AsyncSubject, takeUntil, debounceTime } from 'rxjs' import { Injectable, Inject } from '@angular/core' import { BaseTabComponent } from '../components/baseTab.component' @@ -58,6 +58,7 @@ export class AppService { private tabClosed = new Subject() private tabDragActive = new Subject() private ready = new AsyncSubject() + private recoveryStateChangedHint = new Subject() private completionObservers = new Map() @@ -82,11 +83,16 @@ export class AppService { @Inject(BOOTSTRAP_DATA) private bootstrapData: BootstrapData, ) { this.tabsChanged$.subscribe(() => { + this.recoveryStateChangedHint.next() + }) + + setInterval(() => { + this.recoveryStateChangedHint.next() + }, 30000) + + this.recoveryStateChangedHint.pipe(debounceTime(1000)).subscribe(() => { this.tabRecovery.saveTabs(this.tabs) }) - setInterval(() => { - this.tabRecovery.saveTabs(this.tabs) - }, 30000) config.ready$.toPromise().then(async () => { if (this.bootstrapData.isMainWindow) { @@ -117,7 +123,7 @@ export class AppService { if (this.bootstrapData.isMainWindow) { tab.recoveryStateChangedHint$.subscribe(() => { - this.tabRecovery.saveTabs(this.tabs) + this.recoveryStateChangedHint.next() }) }