diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-09 16:08:09 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-10 14:02:41 +0200 |
commit | 7c87746e4b336e547b1917f274c9a0bdc4d1d3df (patch) | |
tree | b18b6458dc03519a7a25e0b4be8671b3c35b6cc3 /client/src/app | |
parent | f046e2fa5c2af98f378056206ef65347f4b29b8d (diff) | |
download | PeerTube-7c87746e4b336e547b1917f274c9a0bdc4d1d3df.tar.gz PeerTube-7c87746e4b336e547b1917f274c9a0bdc4d1d3df.tar.zst PeerTube-7c87746e4b336e547b1917f274c9a0bdc4d1d3df.zip |
Fix search query when updating from typeahead
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/search/search.component.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/client/src/app/search/search.component.ts b/client/src/app/search/search.component.ts index d3c0761d7..7ab0ed9d6 100644 --- a/client/src/app/search/search.component.ts +++ b/client/src/app/search/search.component.ts | |||
@@ -13,6 +13,7 @@ import { MetaService } from '@ngx-meta/core' | |||
13 | import { I18n } from '@ngx-translate/i18n-polyfill' | 13 | import { I18n } from '@ngx-translate/i18n-polyfill' |
14 | import { ServerConfig } from '@shared/models' | 14 | import { ServerConfig } from '@shared/models' |
15 | import { UserService } from '@app/shared' | 15 | import { UserService } from '@app/shared' |
16 | import { SearchTargetType } from '@shared/models/search/search-target-query.model' | ||
16 | 17 | ||
17 | @Component({ | 18 | @Component({ |
18 | selector: 'my-search', | 19 | selector: 'my-search', |
@@ -40,6 +41,8 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
40 | 41 | ||
41 | private channelsPerPage = 2 | 42 | private channelsPerPage = 2 |
42 | 43 | ||
44 | private lastSearchTarget: SearchTargetType | ||
45 | |||
43 | constructor ( | 46 | constructor ( |
44 | private i18n: I18n, | 47 | private i18n: I18n, |
45 | private route: ActivatedRoute, | 48 | private route: ActivatedRoute, |
@@ -63,9 +66,10 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
63 | this.subActivatedRoute = this.route.queryParams.subscribe( | 66 | this.subActivatedRoute = this.route.queryParams.subscribe( |
64 | async queryParams => { | 67 | async queryParams => { |
65 | const querySearch = queryParams['search'] | 68 | const querySearch = queryParams['search'] |
69 | const searchTarget = queryParams['searchTarget'] | ||
66 | 70 | ||
67 | // Search updated, reset filters | 71 | // Search updated, reset filters |
68 | if (this.currentSearch !== querySearch) { | 72 | if (this.currentSearch !== querySearch || searchTarget !== this.advancedSearch.searchTarget) { |
69 | this.resetPagination() | 73 | this.resetPagination() |
70 | this.advancedSearch.reset() | 74 | this.advancedSearch.reset() |
71 | 75 | ||
@@ -118,6 +122,7 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
118 | .concat(videosResult.data) | 122 | .concat(videosResult.data) |
119 | 123 | ||
120 | this.pagination.totalItems = videosResult.total + videoChannelsResult.total | 124 | this.pagination.totalItems = videosResult.total + videoChannelsResult.total |
125 | this.lastSearchTarget = this.advancedSearch.searchTarget | ||
121 | 126 | ||
122 | // Focus on channels if there are no enough videos | 127 | // Focus on channels if there are no enough videos |
123 | if (this.firstSearch === true && videosResult.data.length < this.pagination.itemsPerPage) { | 128 | if (this.firstSearch === true && videosResult.data.length < this.pagination.itemsPerPage) { |
@@ -182,7 +187,7 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
182 | } | 187 | } |
183 | 188 | ||
184 | hideActions () { | 189 | hideActions () { |
185 | return this.advancedSearch.searchTarget === 'search-index' | 190 | return this.lastSearchTarget === 'search-index' |
186 | } | 191 | } |
187 | 192 | ||
188 | private resetPagination () { | 193 | private resetPagination () { |