-import { Component, Input, Output, OnChanges, EventEmitter } from '@angular/core'
import { Observable } from 'rxjs'
-import { Video } from '@app/shared/video/video.model'
+import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'
+import { AuthService, Notifier } from '@app/core'
+import { User } from '@app/shared'
+import { SessionStorageService } from '@app/shared/misc/storage.service'
+import { UserService } from '@app/shared/users/user.service'
import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
import { RecommendationInfo } from '@app/shared/video/recommendation-info.model'
+import { MiniatureDisplayOptions } from '@app/shared/video/video-miniature.component'
+import { Video } from '@app/shared/video/video.model'
import { RecommendedVideosStore } from '@app/videos/recommendations/recommended-videos.store'
-import { User } from '@app/shared'
-import { AuthService, Notifier } from '@app/core'
-import { UserService } from '@app/shared/users/user.service'
import { I18n } from '@ngx-translate/i18n-polyfill'
-import { SessionStorageService } from '@app/shared/misc/storage.service'
@Component({
selector: 'my-recommended-videos',
templateUrl: './recommended-videos.component.html',
styleUrls: [ './recommended-videos.component.scss' ]
})
-export class RecommendedVideosComponent implements OnChanges {
+export class RecommendedVideosComponent implements OnInit, OnChanges {
@Input() inputRecommendation: RecommendationInfo
- @Input() user: User
@Input() playlist: VideoPlaylist
@Output() gotRecommendations = new EventEmitter<Video[]>()
autoPlayNextVideo: boolean
autoPlayNextVideoTooltip: string
+ displayOptions: MiniatureDisplayOptions = {
+ date: true,
+ views: true,
+ by: true,
+ avatar: true
+ }
+
+ userMiniature: User
+
readonly hasVideos$: Observable<boolean>
readonly videos$: Observable<Video[]>
this.autoPlayNextVideoTooltip = this.i18n('When active, the next video is automatically played after the current one.')
}
- public ngOnChanges (): void {
+ ngOnInit () {
+ this.userService.getAnonymousOrLoggedUser()
+ .subscribe(user => this.userMiniature = user)
+ }
+
+ ngOnChanges () {
if (this.inputRecommendation) {
this.store.requestNewRecommendations(this.inputRecommendation)
}