1 import { 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'
13 export class VideoMiniatureComponent implements OnInit {
16 @Input() ownerDisplayType: OwnerDisplayType = 'account'
18 private ownerDisplayTypeChosen: 'account' | 'videoChannel'
20 constructor (private serverService: ServerService) { }
23 if (this.ownerDisplayType === 'account' || this.ownerDisplayType === 'videoChannel') {
24 this.ownerDisplayTypeChosen = this.ownerDisplayType
28 // If the video channel name an UUID (not really displayable, we changed this behaviour in v1.0.0-beta.12)
29 // -> Use the account name
31 this.video.channel.name === `${this.video.account.name}_channel` ||
32 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}$/)
34 this.ownerDisplayTypeChosen = 'account'
36 this.ownerDisplayTypeChosen = 'videoChannel'
41 return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())
44 displayOwnerAccount () {
45 return this.ownerDisplayTypeChosen === 'account'
48 displayOwnerVideoChannel () {
49 return this.ownerDisplayTypeChosen === 'videoChannel'