1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-25 19:17:39 +03:00

fixed #9751 - title/color observers not detaching when detaching a tab

This commit is contained in:
Eugene 2024-07-18 23:53:23 +02:00
parent b4c3ac8ab6
commit 3d7308cea0
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -1,4 +1,4 @@
import { Observable, Subject } from 'rxjs'
import { Observable, Subject, takeUntil, takeWhile } from 'rxjs'
import { Component, Injectable, ViewChild, ViewContainerRef, EmbeddedViewRef, AfterViewInit, OnDestroy, Injector } from '@angular/core'
import { BaseTabComponent, BaseTabProcess, GetRecoveryTokenOptions } from './baseTab.component'
import { TabRecoveryProvider, RecoveryToken } from '../api/tabRecovery'
@ -837,20 +837,38 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
})
}
tab.subscribeUntilDestroyed(tab.titleChange$, () => this.updateTitle())
tab.subscribeUntilDestroyed(tab.activity$, a => a ? this.displayActivity() : this.clearActivity())
tab.subscribeUntilDestroyed(tab.progress$, p => this.setProgress(p))
tab.subscribeUntilDestroyed(
this.observeUntilChildDetached(tab.titleChange$),
() => this.updateTitle(),
)
tab.subscribeUntilDestroyed(
this.observeUntilChildDetached(tab.activity$),
a => a ? this.displayActivity() : this.clearActivity(),
)
tab.subscribeUntilDestroyed(
this.observeUntilChildDetached(tab.progress$),
p => this.setProgress(p),
)
if (tab.title) {
this.updateTitle()
}
tab.subscribeUntilDestroyed(tab.recoveryStateChangedHint$, () => {
this.recoveryStateChangedHint.next()
})
tab.subscribeUntilDestroyed(
this.observeUntilChildDetached(tab.recoveryStateChangedHint$),
() => {
this.recoveryStateChangedHint.next()
},
)
tab.destroyed$.subscribe(() => {
this.removeTab(tab)
})
}
private observeUntilChildDetached<T> (tab: BaseTabComponent, event: Observable<T>): Observable<T> {
return event.pipe(takeWhile(() => {
this.getAllTabs().includes(tab)
}))
}
private onAfterTabAdded (tab: BaseTabComponent) {
setImmediate(() => {
this.layout()