aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/recommendations
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/recommendations')
-rw-r--r--client/src/app/videos/recommendations/recent-videos-recommendation.service.ts4
-rw-r--r--client/src/app/videos/recommendations/recommended-videos.store.ts14
2 files changed, 11 insertions, 7 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 4723f7fd0..0ee34b9cb 100644
--- a/client/src/app/videos/recommendations/recent-videos-recommendation.service.ts
+++ b/client/src/app/videos/recommendations/recent-videos-recommendation.service.ts
@@ -25,8 +25,8 @@ export class RecentVideosRecommendationService implements RecommendationService
25 getRecommendations (recommendation: RecommendationInfo): Observable<Video[]> { 25 getRecommendations (recommendation: RecommendationInfo): Observable<Video[]> {
26 return this.fetchPage(1, recommendation) 26 return this.fetchPage(1, recommendation)
27 .pipe( 27 .pipe(
28 map(vids => { 28 map(videos => {
29 const otherVideos = vids.filter(v => v.uuid !== recommendation.uuid) 29 const otherVideos = videos.filter(v => v.uuid !== recommendation.uuid)
30 return otherVideos.slice(0, this.pageSize) 30 return otherVideos.slice(0, this.pageSize)
31 }) 31 })
32 ) 32 )
diff --git a/client/src/app/videos/recommendations/recommended-videos.store.ts b/client/src/app/videos/recommendations/recommended-videos.store.ts
index eb5c9867f..858ec3a27 100644
--- a/client/src/app/videos/recommendations/recommended-videos.store.ts
+++ b/client/src/app/videos/recommendations/recommended-videos.store.ts
@@ -3,8 +3,8 @@ import { Observable, ReplaySubject } from 'rxjs'
3import { Video } from '@app/shared/video/video.model' 3import { Video } from '@app/shared/video/video.model'
4import { RecommendationInfo } from '@app/shared/video/recommendation-info.model' 4import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
5import { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service' 5import { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service'
6import { RecommendationService, UUID } from '@app/videos/recommendations/recommendations.service' 6import { RecommendationService } from '@app/videos/recommendations/recommendations.service'
7import { map, switchMap, take } from 'rxjs/operators' 7import { map, shareReplay, switchMap, take } from 'rxjs/operators'
8 8
9/** 9/**
10 * This store is intended to provide data for the RecommendedVideosComponent. 10 * This store is intended to provide data for the RecommendedVideosComponent.
@@ -19,9 +19,13 @@ export class RecommendedVideosStore {
19 @Inject(RecentVideosRecommendationService) private recommendations: RecommendationService 19 @Inject(RecentVideosRecommendationService) private recommendations: RecommendationService
20 ) { 20 ) {
21 this.recommendations$ = this.requestsForLoad$$.pipe( 21 this.recommendations$ = this.requestsForLoad$$.pipe(
22 switchMap(requestedRecommendation => recommendations.getRecommendations(requestedRecommendation) 22 switchMap(requestedRecommendation => {
23 .pipe(take(1)) 23 return recommendations.getRecommendations(requestedRecommendation)
24 )) 24 .pipe(take(1))
25 }),
26 shareReplay()
27 )
28
25 this.hasRecommendations$ = this.recommendations$.pipe( 29 this.hasRecommendations$ = this.recommendations$.pipe(
26 map(otherVideos => otherVideos.length > 0) 30 map(otherVideos => otherVideos.length > 0)
27 ) 31 )