Fix no other videos displayed on some videos
This commit is contained in:
parent
19f2205516
commit
01fe5bd721
|
@ -3,8 +3,8 @@ import { RecommendationService } from '@app/videos/recommendations/recommendatio
|
||||||
import { Video } from '@app/shared/video/video.model'
|
import { Video } from '@app/shared/video/video.model'
|
||||||
import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
|
import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
|
||||||
import { VideoService } from '@app/shared/video/video.service'
|
import { VideoService } from '@app/shared/video/video.service'
|
||||||
import { map } from 'rxjs/operators'
|
import { map, switchMap } from 'rxjs/operators'
|
||||||
import { Observable } from 'rxjs'
|
import { Observable, of } from 'rxjs'
|
||||||
import { SearchService } from '@app/search/search.service'
|
import { SearchService } from '@app/search/search.service'
|
||||||
import { AdvancedSearch } from '@app/search/advanced-search.model'
|
import { AdvancedSearch } from '@app/search/advanced-search.model'
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import { AdvancedSearch } from '@app/search/advanced-search.model'
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RecentVideosRecommendationService implements RecommendationService {
|
export class RecentVideosRecommendationService implements RecommendationService {
|
||||||
|
|
||||||
readonly pageSize = 5
|
readonly pageSize = 5
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
@ -32,24 +31,22 @@ export class RecentVideosRecommendationService implements RecommendationService
|
||||||
}
|
}
|
||||||
|
|
||||||
private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> {
|
private fetchPage (page: number, recommendation: RecommendationInfo): Observable<Video[]> {
|
||||||
let pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 }
|
const pagination = { currentPage: page, itemsPerPage: this.pageSize + 1 }
|
||||||
if (!recommendation.tags) {
|
const defaultSubscription = this.videos.getVideos(pagination, '-createdAt')
|
||||||
return this.videos.getVideos(pagination, '-createdAt')
|
.pipe(map(v => v.videos))
|
||||||
.pipe(
|
|
||||||
map(v => v.videos)
|
if (!recommendation.tags || recommendation.tags.length === 0) return defaultSubscription
|
||||||
)
|
|
||||||
}
|
|
||||||
if (recommendation.tags.length === 0) {
|
|
||||||
return this.videos.getVideos(pagination, '-createdAt')
|
|
||||||
.pipe(
|
|
||||||
map(v => v.videos)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return this.searchService.searchVideos('',
|
return this.searchService.searchVideos('',
|
||||||
pagination,
|
pagination,
|
||||||
new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt' })
|
new AdvancedSearch({ tagsOneOf: recommendation.tags.join(','), sort: '-createdAt' })
|
||||||
).pipe(
|
).pipe(
|
||||||
map(v => v.videos)
|
map(v => v.videos),
|
||||||
|
switchMap(videos => {
|
||||||
|
if (videos.length <= 1) return defaultSubscription
|
||||||
|
|
||||||
|
return of(videos)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ import { Video } from '@app/shared/video/video.model'
|
||||||
import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
|
import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
|
||||||
import { Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
|
|
||||||
export type UUID = string
|
|
||||||
|
|
||||||
export interface RecommendationService {
|
export interface RecommendationService {
|
||||||
getRecommendations (recommendation: RecommendationInfo): Observable<Video[]>
|
getRecommendations (recommendation: RecommendationInfo): Observable<Video[]>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
<div class="other-videos">
|
<div *ngIf="hasVideos$ | async" class="other-videos">
|
||||||
<div i18n class="title-page title-page-single">
|
<div i18n class="title-page title-page-single">
|
||||||
Other videos
|
Other videos
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ng-container *ngIf="hasVideos$ | async">
|
<div *ngFor="let video of (videos$ | async)">
|
||||||
<div *ngFor="let video of (videos$ | async)">
|
<my-video-miniature [video]="video" [user]="user"></my-video-miniature>
|
||||||
<my-video-miniature [video]="video" [user]="user"></my-video-miniature>
|
</div>
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user