]>
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' | |
b0c36821 | 4 | import { RecommendationInfo } from '@app/shared/video/recommendation-info.model' |
7f5f4152 BJ |
5 | import { RecommendedVideosStore } from '@app/videos/recommendations/recommended-videos.store' |
6 | import { User } from '@app/shared' | |
7 | ||
8 | @Component({ | |
9 | selector: 'my-recommended-videos', | |
10 | templateUrl: './recommended-videos.component.html' | |
11 | }) | |
12 | export class RecommendedVideosComponent implements OnChanges { | |
b0c36821 | 13 | @Input() inputRecommendation: RecommendationInfo |
7f5f4152 BJ |
14 | @Input() user: User |
15 | ||
16 | readonly hasVideos$: Observable<boolean> | |
17 | readonly videos$: Observable<Video[]> | |
18 | ||
19 | constructor ( | |
20 | private store: RecommendedVideosStore | |
21 | ) { | |
22 | this.videos$ = this.store.recommendations$ | |
23 | this.hasVideos$ = this.store.hasRecommendations$ | |
24 | } | |
25 | ||
26 | public ngOnChanges (): void { | |
b0c36821 J |
27 | if (this.inputRecommendation) { |
28 | this.store.requestNewRecommendations(this.inputRecommendation) | |
7f5f4152 BJ |
29 | } |
30 | } | |
31 | ||
0a57bbff C |
32 | onVideoRemoved () { |
33 | this.store.requestNewRecommendations(this.inputRecommendation) | |
34 | } | |
7f5f4152 | 35 | } |