diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-19 13:24:31 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-19 13:24:31 +0200 |
commit | 8ece9c8ca0445baffa7b3b16f27f5e4705b8d1ee (patch) | |
tree | 6259034b5ec5dd7090461b999d492d798ddb5d54 /client | |
parent | 4f8b6236689a41dace15701a41954864f33dec9b (diff) | |
download | PeerTube-8ece9c8ca0445baffa7b3b16f27f5e4705b8d1ee.tar.gz PeerTube-8ece9c8ca0445baffa7b3b16f27f5e4705b8d1ee.tar.zst PeerTube-8ece9c8ca0445baffa7b3b16f27f5e4705b8d1ee.zip |
Improve recommended videos without video tags
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts b/client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts index b0ae910ac..8f4594b25 100644 --- a/client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts +++ b/client/src/app/+videos/+video-watch/shared/recommendations/recent-videos-recommendation.service.ts | |||
@@ -39,22 +39,21 @@ export class RecentVideosRecommendationService implements RecommendationService | |||
39 | 39 | ||
40 | private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> { | 40 | private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> { |
41 | const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 } | 41 | const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 } |
42 | const defaultSubscription = this.videos.getVideos({ videoPagination: pagination, sort: '-createdAt' }) | ||
43 | .pipe(map(v => v.data)) | ||
44 | |||
45 | const tags = recommendation.tags | ||
46 | const searchIndexConfig = this.config.search.searchIndex | ||
47 | if ( | ||
48 | !tags || tags.length === 0 || | ||
49 | (searchIndexConfig.enabled === true && searchIndexConfig.disableLocalSearch === true) | ||
50 | ) { | ||
51 | return defaultSubscription | ||
52 | } | ||
53 | 42 | ||
54 | return this.userService.getAnonymousOrLoggedUser() | 43 | return this.userService.getAnonymousOrLoggedUser() |
55 | .pipe( | 44 | .pipe( |
56 | map(user => { | 45 | switchMap(user => { |
57 | return { | 46 | const defaultSubscription = this.videos.getVideos({ |
47 | videoPagination: pagination, | ||
48 | sort: '-publishedAt' | ||
49 | }).pipe(map(v => v.data)) | ||
50 | |||
51 | const searchIndexConfig = this.config.search.searchIndex | ||
52 | if (searchIndexConfig.enabled === true && searchIndexConfig.disableLocalSearch === true) { | ||
53 | return defaultSubscription | ||
54 | } | ||
55 | |||
56 | return this.searchService.searchVideos({ | ||
58 | search: '', | 57 | search: '', |
59 | componentPagination: pagination, | 58 | componentPagination: pagination, |
60 | advancedSearch: new AdvancedSearch({ | 59 | advancedSearch: new AdvancedSearch({ |
@@ -68,14 +67,15 @@ export class RecentVideosRecommendationService implements RecommendationService | |||
68 | ? true | 67 | ? true |
69 | : undefined | 68 | : undefined |
70 | }) | 69 | }) |
71 | } | 70 | }) |
72 | }), | 71 | .pipe( |
73 | switchMap(params => this.searchService.searchVideos(params)), | 72 | map(v => v.data), |
74 | map(v => v.data), | 73 | switchMap(videos => { |
75 | switchMap(videos => { | 74 | if (videos.length <= 1) return defaultSubscription |
76 | if (videos.length <= 1) return defaultSubscription | ||
77 | 75 | ||
78 | return of(videos) | 76 | return of(videos) |
77 | }) | ||
78 | ) | ||
79 | }) | 79 | }) |
80 | ) | 80 | ) |
81 | } | 81 | } |