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'
6 export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto'
9 selector: 'my-video-miniature',
10 styleUrls: [ './video-miniature.component.scss' ],
11 templateUrl: './video-miniature.component.html',
12 changeDetection: ChangeDetectionStrategy.OnPush
14 export class VideoMiniatureComponent implements OnInit {
17 @Input() ownerDisplayType: OwnerDisplayType = 'account'
21 private ownerDisplayTypeChosen: 'account' | 'videoChannel'
23 constructor (private serverService: ServerService) { }
26 if (this.ownerDisplayType === 'account' || this.ownerDisplayType === 'videoChannel') {
27 this.ownerDisplayTypeChosen = this.ownerDisplayType
31 // If the video channel name an UUID (not really displayable, we changed this behaviour in v1.0.0-beta.12)
32 // -> Use the account name
34 this.video.channel.name === `${this.video.account.name}_channel` ||
35 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}$/)
37 this.ownerDisplayTypeChosen = 'account'
39 this.ownerDisplayTypeChosen = 'videoChannel'
42 this.isVideoBlur = this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())
45 displayOwnerAccount () {
46 return this.ownerDisplayTypeChosen === 'account'
49 displayOwnerVideoChannel () {
50 return this.ownerDisplayTypeChosen === 'videoChannel'