diff options
author | Jorropo <jorropo.pgm@gmail.com> | 2018-09-04 11:01:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-04 11:01:54 +0200 |
commit | b0c36821d1dcf362f14c99ca3741e7d03aea0a04 (patch) | |
tree | ba2e84ae6f1559f9e3027feab0422e2bf5ad04a8 /client/src/app/videos/recommendations/recommended-videos.store.ts | |
parent | 5cf84858d49f4231cc4efec5e3132f17f65f6cf6 (diff) | |
download | PeerTube-b0c36821d1dcf362f14c99ca3741e7d03aea0a04.tar.gz PeerTube-b0c36821d1dcf362f14c99ca3741e7d03aea0a04.tar.zst PeerTube-b0c36821d1dcf362f14c99ca3741e7d03aea0a04.zip |
Add video recomandation by tags (#1001)
* Recommendation by tags (thx bradsk88)
Thx bradsk88 for the help.
* Prefer jest-preset-angular to skip need for babel config
* Fix jest
Diffstat (limited to 'client/src/app/videos/recommendations/recommended-videos.store.ts')
-rw-r--r-- | client/src/app/videos/recommendations/recommended-videos.store.ts | 9 |
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 @@ | |||
1 | import { Inject, Injectable } from '@angular/core' | 1 | import { Inject, Injectable } from '@angular/core' |
2 | import { Observable, ReplaySubject } from 'rxjs' | 2 | import { Observable, ReplaySubject } from 'rxjs' |
3 | import { Video } from '@app/shared/video/video.model' | 3 | import { Video } from '@app/shared/video/video.model' |
4 | import { RecommendationInfo } from '@app/shared/video/recommendation-info.model' | ||
4 | import { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service' | 5 | import { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service' |
5 | import { RecommendationService, UUID } from '@app/videos/recommendations/recommendations.service' | 6 | import { RecommendationService, UUID } from '@app/videos/recommendations/recommendations.service' |
6 | import { map, switchMap, take } from 'rxjs/operators' | 7 | import { map, switchMap, take } from 'rxjs/operators' |
@@ -12,13 +13,13 @@ import { map, switchMap, take } from 'rxjs/operators' | |||
12 | export class RecommendedVideosStore { | 13 | export 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 | } |