X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-main%2Fmisc%2Fsimple-search-input.component.ts;h=99abb94e7fa35f4c27f9f23160399a621fe9046b;hb=3afe0ec3b32d2bd9183541ecbf40278710f8707d;hp=292ec4c82b046d60eea2b38b85f23f8e80d2aa98;hpb=9df52d660feb722404be00a50f3c8a612bec1c15;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-main/misc/simple-search-input.component.ts b/client/src/app/shared/shared-main/misc/simple-search-input.component.ts index 292ec4c82..99abb94e7 100644 --- a/client/src/app/shared/shared-main/misc/simple-search-input.component.ts +++ b/client/src/app/shared/shared-main/misc/simple-search-input.component.ts @@ -1,7 +1,4 @@ -import { Subject } from 'rxjs' -import { debounceTime, distinctUntilChanged } from 'rxjs/operators' import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' -import { ActivatedRoute, Router } from '@angular/router' @Component({ selector: 'my-simple-search-input', @@ -22,23 +19,9 @@ export class SimpleSearchInputComponent implements OnInit { value = '' inputShown: boolean - private searchSubject = new Subject() - - constructor ( - private router: Router, - private route: ActivatedRoute - ) {} + private hasAlreadySentSearch = false ngOnInit () { - this.searchSubject - .pipe( - debounceTime(400), - distinctUntilChanged() - ) - .subscribe(value => this.searchChanged.emit(value)) - - this.searchSubject.next(this.value) - if (this.isInputShown()) this.showInput(false) } @@ -54,7 +37,7 @@ export class SimpleSearchInputComponent implements OnInit { return } - this.searchChange() + this.sendSearch() } showInput (focus = true) { @@ -80,9 +63,14 @@ export class SimpleSearchInputComponent implements OnInit { this.hideInput() } - searchChange () { - this.router.navigate([ './search' ], { relativeTo: this.route }) + sendSearch () { + this.hasAlreadySentSearch = true + this.searchChanged.emit(this.value) + } + + onResetFilter () { + this.value = '' - this.searchSubject.next(this.value) + if (this.hasAlreadySentSearch) this.sendSearch() } }