From 36004aa7b0de5cb69a452090770221b192a78eb8 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sun, 19 Apr 2020 23:41:05 +0200 Subject: Support search param in URL for video abuses --- client/src/app/header/search-typeahead.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'client/src/app/header') diff --git a/client/src/app/header/search-typeahead.component.ts b/client/src/app/header/search-typeahead.component.ts index d0350368d..2bf1072f4 100644 --- a/client/src/app/header/search-typeahead.component.ts +++ b/client/src/app/header/search-typeahead.component.ts @@ -36,7 +36,7 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy { ngOnInit () { this.route.queryParams - .pipe(first(params => params.search !== undefined && params.search !== null)) + .pipe(first(params => this.isOnSearch() && params.search !== undefined && params.search !== null)) .subscribe(params => this.search = params.search) this.serverService.getConfig() .subscribe(config => this.serverConfig = config) @@ -146,11 +146,15 @@ export class SearchTypeaheadComponent implements OnInit, OnDestroy { } } + isOnSearch () { + return window.location.pathname === '/search' + } + doSearch () { this.newSearch = false const queryParams: Params = {} - if (window.location.pathname === '/search' && this.route.snapshot.queryParams) { + if (this.isOnSearch() && this.route.snapshot.queryParams) { Object.assign(queryParams, this.route.snapshot.queryParams) } -- cgit v1.2.3