diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-18 11:59:05 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-19 09:54:36 +0200 |
commit | e972e046dbe9b499944c4fab9220eee13e31ac1b (patch) | |
tree | ed2b1128807b052eec954fbde0054d7bd79b5ffc /client/src/app/videos/recommendations/recommended-videos.store.ts | |
parent | 098eb37797fdadd4adf660b76867da68061fd588 (diff) | |
download | PeerTube-e972e046dbe9b499944c4fab9220eee13e31ac1b.tar.gz PeerTube-e972e046dbe9b499944c4fab9220eee13e31ac1b.tar.zst PeerTube-e972e046dbe9b499944c4fab9220eee13e31ac1b.zip |
Don't get recommended videos twice
Diffstat (limited to 'client/src/app/videos/recommendations/recommended-videos.store.ts')
-rw-r--r-- | client/src/app/videos/recommendations/recommended-videos.store.ts | 14 |
1 files changed, 9 insertions, 5 deletions
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' | |||
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 { RecommendationInfo } from '@app/shared/video/recommendation-info.model' |
5 | import { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service' | 5 | import { RecentVideosRecommendationService } from '@app/videos/recommendations/recent-videos-recommendation.service' |
6 | import { RecommendationService, UUID } from '@app/videos/recommendations/recommendations.service' | 6 | import { RecommendationService } from '@app/videos/recommendations/recommendations.service' |
7 | import { map, switchMap, take } from 'rxjs/operators' | 7 | import { 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 | ) |