]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/video/video-miniature.component.ts
Merge branch 'release/v1.0.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video / video-miniature.component.ts
CommitLineData
89724816 1import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'
b1fa3eba
C
2import { User } from '../users'
3import { Video } from './video.model'
0883b324 4import { ServerService } from '@app/core'
017c3dca 5import { VideoPrivacy } from '../../../../../shared'
501bc6c2 6
22a16e36
C
7export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto'
8
501bc6c2
C
9@Component({
10 selector: 'my-video-miniature',
ec8d8440 11 styleUrls: [ './video-miniature.component.scss' ],
89724816
C
12 templateUrl: './video-miniature.component.html',
13 changeDetection: ChangeDetectionStrategy.OnPush
501bc6c2 14})
22a16e36 15export class VideoMiniatureComponent implements OnInit {
df98563e
C
16 @Input() user: User
17 @Input() video: Video
22a16e36
C
18 @Input() ownerDisplayType: OwnerDisplayType = 'account'
19
20 private ownerDisplayTypeChosen: 'account' | 'videoChannel'
501bc6c2 21
0883b324
C
22 constructor (private serverService: ServerService) { }
23
d1a63fc7
C
24 get isVideoBlur () {
25 return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig())
26 }
27
22a16e36
C
28 ngOnInit () {
29 if (this.ownerDisplayType === 'account' || this.ownerDisplayType === 'videoChannel') {
30 this.ownerDisplayTypeChosen = this.ownerDisplayType
31 return
32 }
33
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
36 if (
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}$/)
39 ) {
40 this.ownerDisplayTypeChosen = 'account'
41 } else {
42 this.ownerDisplayTypeChosen = 'videoChannel'
43 }
92fb909c 44 }
22a16e36
C
45
46 displayOwnerAccount () {
47 return this.ownerDisplayTypeChosen === 'account'
48 }
49
50 displayOwnerVideoChannel () {
51 return this.ownerDisplayTypeChosen === 'videoChannel'
52 }
017c3dca
C
53
54 isUnlistedVideo () {
55 return this.video.privacy.id === VideoPrivacy.UNLISTED
56 }
57
58 isPrivateVideo () {
59 return this.video.privacy.id === VideoPrivacy.PRIVATE
60 }
501bc6c2 61}