aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-28 14:51:30 +0200
committerChocobozzz <me@florianbigard.com>2018-09-28 14:51:30 +0200
commit01fe5bd721ae99569f776ad362ebdaa5ba8f494f (patch)
tree1acfe24beb2531987660578524be324b2885525f /client/src
parent19f22055162185d5f46d5916c82de3639de209a1 (diff)
downloadPeerTube-01fe5bd721ae99569f776ad362ebdaa5ba8f494f.tar.gz
PeerTube-01fe5bd721ae99569f776ad362ebdaa5ba8f494f.tar.zst
PeerTube-01fe5bd721ae99569f776ad362ebdaa5ba8f494f.zip
Fix no other videos displayed on some videos
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/videos/recommendations/recent-videos-recommendation.service.ts31
-rw-r--r--client/src/app/videos/recommendations/recommendations.service.ts2
-rw-r--r--client/src/app/videos/recommendations/recommended-videos.component.html10
3 files changed, 18 insertions, 25 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 59acf17bc..6d7b159da 100644
--- a/client/src/app/videos/recommendations/recent-videos-recommendation.service.ts
+++ b/client/src/app/videos/recommendations/recent-videos-recommendation.service.ts
@@ -3,8 +3,8 @@ import { RecommendationService } from '@app/videos/recommendations/recommendatio
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 { VideoService } from '@app/shared/video/video.service' 5import { VideoService } from '@app/shared/video/video.service'
6import { map } from 'rxjs/operators' 6import { map, switchMap } from 'rxjs/operators'
7import { Observable } from 'rxjs' 7import { Observable, of } from 'rxjs'
8import { SearchService } from '@app/search/search.service' 8import { SearchService } from '@app/search/search.service'
9import { AdvancedSearch } from '@app/search/advanced-search.model' 9import { AdvancedSearch } from '@app/search/advanced-search.model'
10 10
@@ -13,7 +13,6 @@ import { AdvancedSearch } from '@app/search/advanced-search.model'
13 */ 13 */
14@Injectable() 14@Injectable()
15export class RecentVideosRecommendationService implements RecommendationService { 15export class RecentVideosRecommendationService implements RecommendationService {
16
17 readonly pageSize = 5 16 readonly pageSize = 5
18 17
19 constructor ( 18 constructor (
@@ -32,24 +31,22 @@ export class RecentVideosRecommendationService implements RecommendationService
32 } 31 }
33 32
34 private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> { 33 private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> {
35 let pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 } 34 const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 }
36 if (!recommendation.tags) { 35 const defaultSubscription = this.videos.getVideos(pagination, '-createdAt')
37 return this.videos.getVideos(pagination, '-createdAt') 36 .pipe(map(v => v.videos))
38 .pipe( 37
39 map(v => v.videos) 38 if (!recommendation.tags || recommendation.tags.length === 0) return defaultSubscription
40 ) 39
41 }
42 if (recommendation.tags.length === 0) {
43 return this.videos.getVideos(pagination, '-createdAt')
44 .pipe(
45 map(v => v.videos)
46 )
47 }
48 return this.searchService.searchVideos('', 40 return this.searchService.searchVideos('',
49 pagination, 41 pagination,
50 new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt' }) 42 new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt' })
51 ).pipe( 43 ).pipe(
52 map(v => v.videos) 44 map(v => v.videos),
45 switchMap(videos => {
46 if (videos.length <= 1) return defaultSubscription
47
48 return of(videos)
49 })
53 ) 50 )
54 } 51 }
55} 52}
diff --git a/client/src/app/videos/recommendations/recommendations.service.ts b/client/src/app/videos/recommendations/recommendations.service.ts
index 114a808b5..a547e289d 100644
--- a/client/src/app/videos/recommendations/recommendations.service.ts
+++ b/client/src/app/videos/recommendations/recommendations.service.ts
@@ -2,8 +2,6 @@ import { Video } from '@app/shared/video/video.model'
2import { RecommendationInfo } from '@app/shared/video/recommendation-info.model' 2import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
3import { Observable } from 'rxjs' 3import { Observable } from 'rxjs'
4 4
5export type UUID = string
6
7export interface RecommendationService { 5export interface RecommendationService {
8 getRecommendations (recommendation: RecommendationInfo): Observable<Video[]> 6 getRecommendations (recommendation: RecommendationInfo): Observable<Video[]>
9} 7}
diff --git a/client/src/app/videos/recommendations/recommended-videos.component.html b/client/src/app/videos/recommendations/recommended-videos.component.html
index 7cfaffec2..73f9f0fe1 100644
--- a/client/src/app/videos/recommendations/recommended-videos.component.html
+++ b/client/src/app/videos/recommendations/recommended-videos.component.html
@@ -1,11 +1,9 @@
1<div class="other-videos"> 1<div *ngIf="hasVideos$ | async" class="other-videos">
2 <div i18n class="title-page title-page-single"> 2 <div i18n class="title-page title-page-single">
3 Other videos 3 Other videos
4 </div> 4 </div>
5 5
6 <ng-container *ngIf="hasVideos$ | async"> 6 <div *ngFor="let video of (videos$ | async)">
7 <div *ngFor="let video of (videos$ | async)"> 7 <my-video-miniature [video]="video" [user]="user"></my-video-miniature>
8 <my-video-miniature [video]="video" [user]="user"></my-video-miniature> 8 </div>
9 </div>
10 </ng-container>
11</div> 9</div>