]>
Commit | Line | Data |
---|---|---|
7f5f4152 BJ |
1 | import { Component, Input, OnChanges } from '@angular/core' |
2 | import { Observable } from 'rxjs' | |
3 | import { Video } from '@app/shared/video/video.model' | |
4 | import { RecommendedVideosStore } from '@app/videos/recommendations/recommended-videos.store' | |
5 | import { User } from '@app/shared' | |
6 | ||
7 | @Component({ | |
8 | selector: 'my-recommended-videos', | |
9 | templateUrl: './recommended-videos.component.html' | |
10 | }) | |
11 | export class RecommendedVideosComponent implements OnChanges { | |
12 | @Input() inputVideo: Video | |
13 | @Input() user: User | |
14 | ||
15 | readonly hasVideos$: Observable<boolean> | |
16 | readonly videos$: Observable<Video[]> | |
17 | ||
18 | constructor ( | |
19 | private store: RecommendedVideosStore | |
20 | ) { | |
21 | this.videos$ = this.store.recommendations$ | |
22 | this.hasVideos$ = this.store.hasRecommendations$ | |
23 | } | |
24 | ||
25 | public ngOnChanges (): void { | |
26 | if (this.inputVideo) { | |
27 | this.store.requestNewRecommendations(this.inputVideo.uuid) | |
28 | } | |
29 | } | |
30 | ||
31 | } |