From 93cae47925e4dd68b7d34a41927b2740b4fab1b4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 22 Jul 2019 15:40:13 +0200 Subject: Add client hooks --- .../recent-videos-recommendation.service.ts | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'client/src/app/videos/recommendations') diff --git a/client/src/app/videos/recommendations/recent-videos-recommendation.service.ts b/client/src/app/videos/recommendations/recent-videos-recommendation.service.ts index f975ff6ef..a1e65c27c 100644 --- a/client/src/app/videos/recommendations/recent-videos-recommendation.service.ts +++ b/client/src/app/videos/recommendations/recent-videos-recommendation.service.ts @@ -33,20 +33,24 @@ export class RecentVideosRecommendationService implements RecommendationService private fetchPage (page: number, recommendation: RecommendationInfo): Observable { const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 } const defaultSubscription = this.videos.getVideos({ videoPagination: pagination, sort: '-createdAt' }) - .pipe(map(v => v.videos)) + .pipe(map(v => v.data)) if (!recommendation.tags || recommendation.tags.length === 0) return defaultSubscription - return this.searchService.searchVideos('', - pagination, - new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt' }) - ).pipe( - map(v => v.videos), - switchMap(videos => { - if (videos.length <= 1) return defaultSubscription - - return of(videos) - }) - ) + const params = { + search: '', + componentPagination: pagination, + advancedSearch: new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt' }) + } + + return this.searchService.searchVideos(params) + .pipe( + map(v => v.data), + switchMap(videos => { + if (videos.length <= 1) return defaultSubscription + + return of(videos) + }) + ) } } -- cgit v1.2.3