Skip to content

Commit

Permalink
fixed #9751 - title/color observers not detaching when detaching a tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Jul 18, 2024
1 parent b4c3ac8 commit 3d7308c
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions tabby-core/src/components/splitTab.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Observable, Subject } from 'rxjs'
import { Observable, Subject, takeUntil, takeWhile } from 'rxjs'

Check failure on line 1 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / build

'takeUntil' is declared but its value is never read.

Check failure on line 1 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

'takeUntil' is declared but its value is never read.

Check failure on line 1 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

'takeUntil' is defined but never used
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'
Expand Down Expand Up @@ -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$),

Check failure on line 841 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / build

Expected 2 arguments, but got 1.

Check failure on line 841 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Expected 2 arguments, but got 1.
() => this.updateTitle(),
)
tab.subscribeUntilDestroyed(
this.observeUntilChildDetached(tab.activity$),

Check failure on line 845 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / build

Expected 2 arguments, but got 1.

Check failure on line 845 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Expected 2 arguments, but got 1.
a => a ? this.displayActivity() : this.clearActivity(),
)
tab.subscribeUntilDestroyed(
this.observeUntilChildDetached(tab.progress$),

Check failure on line 849 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / build

Expected 2 arguments, but got 1.

Check failure on line 849 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Expected 2 arguments, but got 1.
p => this.setProgress(p),

Check failure on line 850 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / build

Argument of type 'unknown' is not assignable to parameter of type 'number | null'.

Check failure on line 850 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Argument of type 'unknown' is not assignable to parameter of type 'number | null'.
)
if (tab.title) {
this.updateTitle()
}
tab.subscribeUntilDestroyed(tab.recoveryStateChangedHint$, () => {
this.recoveryStateChangedHint.next()
})
tab.subscribeUntilDestroyed(
this.observeUntilChildDetached(tab.recoveryStateChangedHint$),

Check failure on line 856 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / build

Expected 2 arguments, but got 1.

Check failure on line 856 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

Expected 2 arguments, but got 1.
() => {
this.recoveryStateChangedHint.next()
},
)
tab.destroyed$.subscribe(() => {
this.removeTab(tab)
})
}

private observeUntilChildDetached<T> (tab: BaseTabComponent, event: Observable<T>): Observable<T> {
return event.pipe(takeWhile(() => {

Check failure on line 867 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / build

No overload matches this call.

Check failure on line 867 in tabby-core/src/components/splitTab.component.ts

View workflow job for this annotation

GitHub Actions / Lint

No overload matches this call.
this.getAllTabs().includes(tab)
}))
}

private onAfterTabAdded (tab: BaseTabComponent) {
setImmediate(() => {
this.layout()
Expand Down

0 comments on commit 3d7308c

Please sign in to comment.