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 | |
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')
3 files changed, 12 insertions, 8 deletions
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 834428fa4..7a61e355a 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { catchError, subscribeOn } from 'rxjs/operators' | 1 | import { catchError } from 'rxjs/operators' |
2 | import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' | 2 | import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { RedirectService } from '@app/core/routing/redirect.service' | 4 | import { RedirectService } from '@app/core/routing/redirect.service' |
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' | |||
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 | ) |