aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/recommendations/recommended-videos.store.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/recommendations/recommended-videos.store.ts')
-rw-r--r--client/src/app/videos/recommendations/recommended-videos.store.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/client/src/app/videos/recommendations/recommended-videos.store.ts b/client/src/app/videos/recommendations/recommended-videos.store.ts
index 689adeb1f..eb5c9867f 100644
--- a/client/src/app/videos/recommendations/recommended-videos.store.ts
+++ b/client/src/app/videos/recommendations/recommended-videos.store.ts
@@ -1,6 +1,7 @@
1import { Inject, Injectable } from '@angular/core' 1import { Inject, Injectable } from '@angular/core'
2import { Observable, ReplaySubject } from 'rxjs' 2import { 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 { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service' 5import { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service'
5import { RecommendationService, UUID } from '@app/videos/recommendations/recommendations.service' 6import { RecommendationService, UUID } from '@app/videos/recommendations/recommendations.service'
6import { map, switchMap, take } from 'rxjs/operators' 7import { map, switchMap, take } from 'rxjs/operators'
@@ -12,13 +13,13 @@ import { map, switchMap, take } from 'rxjs/operators'
12export class RecommendedVideosStore { 13export class RecommendedVideosStore {
13 public readonly recommendations$: Observable<Video[]> 14 public readonly recommendations$: Observable<Video[]>
14 public readonly hasRecommendations$: Observable<boolean> 15 public readonly hasRecommendations$: Observable<boolean>
15 private readonly requestsForLoad$$ = new ReplaySubject<UUID>(1) 16 private readonly requestsForLoad$$ = new ReplaySubject<RecommendationInfo>(1)
16 17
17 constructor ( 18 constructor (
18 @Inject(RecentVideosRecommendationService) private recommendations: RecommendationService 19 @Inject(RecentVideosRecommendationService) private recommendations: RecommendationService
19 ) { 20 ) {
20 this.recommendations$ = this.requestsForLoad$$.pipe( 21 this.recommendations$ = this.requestsForLoad$$.pipe(
21 switchMap(requestedUUID => recommendations.getRecommendations(requestedUUID) 22 switchMap(requestedRecommendation => recommendations.getRecommendations(requestedRecommendation)
22 .pipe(take(1)) 23 .pipe(take(1))
23 )) 24 ))
24 this.hasRecommendations$ = this.recommendations$.pipe( 25 this.hasRecommendations$ = this.recommendations$.pipe(
@@ -26,7 +27,7 @@ export class RecommendedVideosStore {
26 ) 27 )
27 } 28 }
28 29
29 requestNewRecommendations (videoUUID: string) { 30 requestNewRecommendations (recommend: RecommendationInfo) {
30 this.requestsForLoad$$.next(videoUUID) 31 this.requestsForLoad$$.next(recommend)
31 } 32 }
32} 33}