X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bsearch%2Fsearch.component.ts;h=366fbd459906b293f085fabb2cbb533b3ae41543;hb=4158e67c8d7eb39712e598d3f409c6739eef5f0b;hp=81d1006f8ea0840788cbe167e8f05728182ca9dc;hpb=1378c0d343028f3d40d7d795422684ab9e6a1599;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+search/search.component.ts b/client/src/app/+search/search.component.ts index 81d1006f8..366fbd459 100644 --- a/client/src/app/+search/search.component.ts +++ b/client/src/app/+search/search.component.ts @@ -47,10 +47,6 @@ export class SearchComponent implements OnInit, OnDestroy { private subActivatedRoute: Subscription private isInitialLoad = false // set to false to show the search filters on first arrival - private channelsPerPage = 2 - private playlistsPerPage = 2 - private videosPerPage = 10 - private hasMoreResults = true private isSearching = false @@ -75,7 +71,7 @@ export class SearchComponent implements OnInit, OnDestroy { this.subActivatedRoute = this.route.queryParams .subscribe({ - next: async queryParams => { + next: queryParams => { const querySearch = queryParams['search'] const searchTarget = queryParams['searchTarget'] @@ -102,7 +98,7 @@ export class SearchComponent implements OnInit, OnDestroy { this.search() }, - error: err => this.notifier.error(err.text) + error: err => this.notifier.error(err.message) }) this.userService.getAnonymousOrLoggedUser() @@ -247,17 +243,16 @@ export class SearchComponent implements OnInit, OnDestroy { private resetPagination () { this.pagination.currentPage = 1 this.pagination.totalItems = null - this.channelsPerPage = 2 this.results = [] } private updateTitle () { - const suffix = this.currentSearch - ? ' ' + this.currentSearch - : '' + const title = this.currentSearch + ? $localize`Search ${this.currentSearch}` + : $localize`Search` - this.metaService.setTitle($localize`Search` + suffix) + this.metaService.setTitle(title) } private updateUrlFromAdvancedSearch () { @@ -272,7 +267,7 @@ export class SearchComponent implements OnInit, OnDestroy { private getVideosObs () { const params = { search: this.currentSearch, - componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.videosPerPage }), + componentPagination: immutableAssign(this.pagination, { itemsPerPage: 10 }), advancedSearch: this.advancedSearch } @@ -288,7 +283,7 @@ export class SearchComponent implements OnInit, OnDestroy { private getVideoChannelObs () { const params = { search: this.currentSearch, - componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.channelsPerPage }), + componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.buildChannelsPerPage() }), advancedSearch: this.advancedSearch } @@ -304,7 +299,7 @@ export class SearchComponent implements OnInit, OnDestroy { private getVideoPlaylistObs () { const params = { search: this.currentSearch, - componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.playlistsPerPage }), + componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.buildPlaylistsPerPage() }), advancedSearch: this.advancedSearch } @@ -334,4 +329,16 @@ export class SearchComponent implements OnInit, OnDestroy { return undefined } + + private buildChannelsPerPage () { + if (this.advancedSearch.resultType === 'channels') return 10 + + return 2 + } + + private buildPlaylistsPerPage () { + if (this.advancedSearch.resultType === 'playlists') return 10 + + return 2 + } }