mirror of
https://github.com/Eugeny/tabby
synced 2024-12-13 14:52:45 +00:00
debounce tab progress updates
This commit is contained in:
parent
53cbb8a7e3
commit
88bbdd0da1
3 changed files with 13 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
|||
import { Observable, Subject, distinctUntilChanged } from 'rxjs'
|
||||
import { Observable, Subject, distinctUntilChanged, filter, debounceTime } from 'rxjs'
|
||||
import { EmbeddedViewRef, ViewContainerRef, ViewRef } from '@angular/core'
|
||||
import { RecoveryToken } from '../api/tabRecovery'
|
||||
import { BaseComponent } from './base.component'
|
||||
|
@ -61,7 +61,6 @@ export abstract class BaseTabComponent extends BaseComponent {
|
|||
/* @hidden */
|
||||
viewContainerEmbeddedRef?: EmbeddedViewRef<any>
|
||||
|
||||
private progressClearTimeout: number
|
||||
private titleChange = new Subject<string>()
|
||||
private focused = new Subject<void>()
|
||||
private blurred = new Subject<void>()
|
||||
|
@ -87,6 +86,12 @@ export abstract class BaseTabComponent extends BaseComponent {
|
|||
this.blurred$.subscribe(() => {
|
||||
this.hasFocus = false
|
||||
})
|
||||
this.subscribeUntilDestroyed(this.progress.pipe(
|
||||
filter(x => x !== null),
|
||||
debounceTime(5000),
|
||||
), () => {
|
||||
this.setProgress(null)
|
||||
})
|
||||
}
|
||||
|
||||
setTitle (title: string): void {
|
||||
|
@ -103,14 +108,6 @@ export abstract class BaseTabComponent extends BaseComponent {
|
|||
*/
|
||||
setProgress (progress: number|null): void {
|
||||
this.progress.next(progress)
|
||||
if (progress) {
|
||||
if (this.progressClearTimeout) {
|
||||
clearTimeout(this.progressClearTimeout)
|
||||
}
|
||||
this.progressClearTimeout = setTimeout(() => {
|
||||
this.setProgress(null)
|
||||
}, 5000) as any
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Component, Input, Optional, Inject, HostBinding, HostListener, NgZone } from '@angular/core'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { auditTime } from 'rxjs'
|
||||
import { TabContextMenuItemProvider } from '../api/tabContextMenuProvider'
|
||||
import { BaseTabComponent } from './baseTab.component'
|
||||
import { RenameTabModalComponent } from './renameTabModal.component'
|
||||
|
@ -47,7 +48,9 @@ export class TabHeaderComponent extends BaseComponent {
|
|||
}
|
||||
|
||||
ngOnInit () {
|
||||
this.subscribeUntilDestroyed(this.tab.progress$, progress => {
|
||||
this.subscribeUntilDestroyed(this.tab.progress$.pipe(
|
||||
auditTime(300),
|
||||
), progress => {
|
||||
this.zone.run(() => {
|
||||
this.progress = progress
|
||||
})
|
||||
|
|
|
@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'
|
|||
import { PlatformService, LogService, UpdaterService, DockingService, HostAppService, ThemesService, Platform, AppService, ConfigService, WIN_BUILD_FLUENT_BG_SUPPORTED, isWindowsBuild, HostWindowService, HotkeyProvider, ConfigProvider, FileProvider } from 'tabby-core'
|
||||
import { TerminalColorSchemeProvider } from 'tabby-terminal'
|
||||
import { SFTPContextMenuItemProvider } from 'tabby-ssh'
|
||||
import { auditTime } from 'rxjs'
|
||||
|
||||
import { HyperColorSchemes } from './colorSchemes'
|
||||
import { ElectronPlatformService } from './services/platform.service'
|
||||
|
@ -68,7 +69,7 @@ export default class ElectronModule {
|
|||
|
||||
let lastProgress: number|null = null
|
||||
app.tabOpened$.subscribe(tab => {
|
||||
tab.progress$.subscribe(progress => {
|
||||
tab.progress$.pipe(auditTime(250)).subscribe(progress => {
|
||||
if (lastProgress === progress) {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue