]>
Commit | Line | Data |
---|---|---|
22a16e36 | 1 | import { Component, Input, OnInit } from '@angular/core' |
b1fa3eba C |
2 | import { User } from '../users' |
3 | import { Video } from './video.model' | |
0883b324 | 4 | import { ServerService } from '@app/core' |
501bc6c2 | 5 | |
22a16e36 C |
6 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' |
7 | ||
501bc6c2 C |
8 | @Component({ |
9 | selector: 'my-video-miniature', | |
ec8d8440 C |
10 | styleUrls: [ './video-miniature.component.scss' ], |
11 | templateUrl: './video-miniature.component.html' | |
501bc6c2 | 12 | }) |
22a16e36 | 13 | export class VideoMiniatureComponent implements OnInit { |
df98563e C |
14 | @Input() user: User |
15 | @Input() video: Video | |
22a16e36 C |
16 | @Input() ownerDisplayType: OwnerDisplayType = 'account' |
17 | ||
18 | private ownerDisplayTypeChosen: 'account' | 'videoChannel' | |
501bc6c2 | 19 | |
0883b324 C |
20 | constructor (private serverService: ServerService) { } |
21 | ||
22a16e36 C |
22 | ngOnInit () { |
23 | if (this.ownerDisplayType === 'account' || this.ownerDisplayType === 'videoChannel') { | |
24 | this.ownerDisplayTypeChosen = this.ownerDisplayType | |
25 | return | |
26 | } | |
27 | ||
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 | |
30 | if ( | |
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}$/) | |
33 | ) { | |
34 | this.ownerDisplayTypeChosen = 'account' | |
35 | } else { | |
36 | this.ownerDisplayTypeChosen = 'videoChannel' | |
37 | } | |
38 | } | |
39 | ||
0883b324 C |
40 | isVideoBlur () { |
41 | return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) | |
92fb909c | 42 | } |
22a16e36 C |
43 | |
44 | displayOwnerAccount () { | |
45 | return this.ownerDisplayTypeChosen === 'account' | |
46 | } | |
47 | ||
48 | displayOwnerVideoChannel () { | |
49 | return this.ownerDisplayTypeChosen === 'videoChannel' | |
50 | } | |
501bc6c2 | 51 | } |