aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/recommendations
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-22 15:40:13 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit93cae47925e4dd68b7d34a41927b2740b4fab1b4 (patch)
treef649ab49fab1886b434e164591990cc99b234466 /client/src/app/videos/recommendations
parent587568e1cc0e33c023c1ac62dd28fef313285250 (diff)
downloadPeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.tar.gz
PeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.tar.zst
PeerTube-93cae47925e4dd68b7d34a41927b2740b4fab1b4.zip
Add client hooks
Diffstat (limited to 'client/src/app/videos/recommendations')
-rw-r--r--client/src/app/videos/recommendations/recent-videos-recommendation.service.ts28
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}