1 import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'
2 import { User } from '../users'
3 import { Video } from './video.model'
4 import { ServerService } from '@app/core'
5 import { VideoPrivacy } from '../../../../../shared'
7 export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto'
10 selector: 'my-video-miniature',
11 styleUrls: [ './video-miniature.component.scss' ],
12 templateUrl: './video-miniature.component.html',
13 changeDetection: ChangeDetectionStrategy.OnPush
15 export class VideoMiniatureComponent implements OnInit {
18 @Input() ownerDisplayType: OwnerDisplayType = 'account'
20 private ownerDisplayTypeChosen: 'account' | 'videoChannel'
22 constructor (private serverService: ServerService) { }
25 return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())
29 if (this.ownerDisplayType === 'account' || this.ownerDisplayType === 'videoChannel') {
30 this.ownerDisplayTypeChosen = this.ownerDisplayType
34 // If the video channel name an UUID (not really displayable, we changed this behaviour in v1.0.0-beta.12)
35 // -> Use the account name
37 this.video.channel.name === `${this.video.account.name}_channel` ||
38 this.video.channel.name.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)
40 this.ownerDisplayTypeChosen = 'account'
42 this.ownerDisplayTypeChosen = 'videoChannel'
46 displayOwnerAccount () {
47 return this.ownerDisplayTypeChosen === 'account'
50 displayOwnerVideoChannel () {
51 return this.ownerDisplayTypeChosen === 'videoChannel'
55 return this.video.privacy.id === VideoPrivacy.UNLISTED
59 return this.video.privacy.id === VideoPrivacy.PRIVATE