From 8ece9c8ca0445baffa7b3b16f27f5e4705b8d1ee Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 19 Jul 2023 13:24:31 +0200 Subject: [PATCH] Improve recommended videos without video tags --- .../recent-videos-recommendation.service.ts | 40 +++++++++---------- 1 file 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 private fetchPage (page: number, recommendation: RecommendationInfo): Observable { const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 } - const defaultSubscription = this.videos.getVideos({ videoPagination: pagination, sort: '-createdAt' }) - .pipe(map(v => v.data)) - - const tags = recommendation.tags - const searchIndexConfig = this.config.search.searchIndex - if ( - !tags || tags.length === 0 || - (searchIndexConfig.enabled === true && searchIndexConfig.disableLocalSearch === true) - ) { - return defaultSubscription - } return this.userService.getAnonymousOrLoggedUser() .pipe( - map(user => { - return { + switchMap(user => { + const defaultSubscription = this.videos.getVideos({ + videoPagination: pagination, + sort: '-publishedAt' + }).pipe(map(v => v.data)) + + const searchIndexConfig = this.config.search.searchIndex + if (searchIndexConfig.enabled === true && searchIndexConfig.disableLocalSearch === true) { + return defaultSubscription + } + + return this.searchService.searchVideos({ search: '', componentPagination: pagination, advancedSearch: new AdvancedSearch({ @@ -68,14 +67,15 @@ export class RecentVideosRecommendationService implements RecommendationService ? true : undefined }) - } - }), - switchMap(params => this.searchService.searchVideos(params)), - map(v => v.data), - switchMap(videos => { - if (videos.length <= 1) return defaultSubscription + }) + .pipe( + map(v => v.data), + switchMap(videos => { + if (videos.length <= 1) return defaultSubscription - return of(videos) + return of(videos) + }) + ) }) ) }