mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-24 05:19:57 +00:00
debounce typing in search field - fixes #7579
This commit is contained in:
parent
a4c8aa40b5
commit
145b6447b9
@ -1,4 +1,5 @@
|
|||||||
import { Component, Input, Output, EventEmitter } from '@angular/core'
|
import { Component, Input, Output, EventEmitter } from '@angular/core'
|
||||||
|
import { Subject, debounceTime } from 'rxjs'
|
||||||
import { Frontend, SearchOptions, SearchState } from '../frontends/frontend'
|
import { Frontend, SearchOptions, SearchState } from '../frontends/frontend'
|
||||||
import { ConfigService, NotificationsService, TranslateService } from 'tabby-core'
|
import { ConfigService, NotificationsService, TranslateService } from 'tabby-core'
|
||||||
|
|
||||||
@ -18,6 +19,8 @@ export class SearchPanelComponent {
|
|||||||
|
|
||||||
@Output() close = new EventEmitter()
|
@Output() close = new EventEmitter()
|
||||||
|
|
||||||
|
private queryChanged = new Subject<string>()
|
||||||
|
|
||||||
icons = {
|
icons = {
|
||||||
'case': require('../icons/case.svg'),
|
'case': require('../icons/case.svg'),
|
||||||
regexp: require('../icons/regexp.svg'),
|
regexp: require('../icons/regexp.svg'),
|
||||||
@ -31,11 +34,15 @@ export class SearchPanelComponent {
|
|||||||
private notifications: NotificationsService,
|
private notifications: NotificationsService,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
public config: ConfigService,
|
public config: ConfigService,
|
||||||
) { }
|
) {
|
||||||
|
this.queryChanged.pipe(debounceTime(250)).subscribe(() => {
|
||||||
|
this.findPrevious(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onQueryChange (): void {
|
onQueryChange (): void {
|
||||||
this.state = { resultCount: 0 }
|
this.state = { resultCount: 0 }
|
||||||
this.findPrevious(true)
|
this.queryChanged.next(this.query)
|
||||||
}
|
}
|
||||||
|
|
||||||
findNext (incremental = false): void {
|
findNext (incremental = false): void {
|
||||||
@ -65,4 +72,8 @@ export class SearchPanelComponent {
|
|||||||
|
|
||||||
this.config.save()
|
this.config.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy () {
|
||||||
|
this.queryChanged.complete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user