diff options
Diffstat (limited to 'client/src/app/videos/recommendations')
-rw-r--r-- | client/src/app/videos/recommendations/recent-videos-recommendation.service.ts | 28 |
1 files changed, 16 insertions, 12 deletions
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 | |||
33 | private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> { | 33 | private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> { |
34 | const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 } | 34 | const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 } |
35 | const defaultSubscription = this.videos.getVideos({ videoPagination: pagination, sort: '-createdAt' }) | 35 | const defaultSubscription = this.videos.getVideos({ videoPagination: pagination, sort: '-createdAt' }) |
36 | .pipe(map(v => v.videos)) | 36 | .pipe(map(v => v.data)) |
37 | 37 | ||
38 | if (!recommendation.tags || recommendation.tags.length === 0) return defaultSubscription | 38 | if (!recommendation.tags || recommendation.tags.length === 0) return defaultSubscription |
39 | 39 | ||
40 | return this.searchService.searchVideos('', | 40 | const params = { |
41 | pagination, | 41 | search: '', |
42 | new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt' }) | 42 | componentPagination: pagination, |
43 | ).pipe( | 43 | advancedSearch: new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt' }) |
44 | map(v => v.videos), | 44 | } |
45 | switchMap(videos => { | 45 | |
46 | if (videos.length <= 1) return defaultSubscription | 46 | return this.searchService.searchVideos(params) |
47 | 47 | .pipe( | |
48 | return of(videos) | 48 | map(v => v.data), |
49 | }) | 49 | switchMap(videos => { |
50 | ) | 50 | if (videos.length <= 1) return defaultSubscription |
51 | |||
52 | return of(videos) | ||
53 | }) | ||
54 | ) | ||
51 | } | 55 | } |
52 | } | 56 | } |