diff options
Diffstat (limited to 'client/src/app/shared/video/video-miniature.component.ts')
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.ts | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts index d3f6dc1f6..07193ebd5 100644 --- a/client/src/app/shared/video/video-miniature.component.ts +++ b/client/src/app/shared/video/video-miniature.component.ts | |||
@@ -1,20 +1,51 @@ | |||
1 | import { Component, Input } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { User } from '../users' | 2 | import { User } from '../users' |
3 | import { Video } from './video.model' | 3 | import { Video } from './video.model' |
4 | import { ServerService } from '@app/core' | 4 | import { ServerService } from '@app/core' |
5 | 5 | ||
6 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' | ||
7 | |||
6 | @Component({ | 8 | @Component({ |
7 | selector: 'my-video-miniature', | 9 | selector: 'my-video-miniature', |
8 | styleUrls: [ './video-miniature.component.scss' ], | 10 | styleUrls: [ './video-miniature.component.scss' ], |
9 | templateUrl: './video-miniature.component.html' | 11 | templateUrl: './video-miniature.component.html' |
10 | }) | 12 | }) |
11 | export class VideoMiniatureComponent { | 13 | export class VideoMiniatureComponent implements OnInit { |
12 | @Input() user: User | 14 | @Input() user: User |
13 | @Input() video: Video | 15 | @Input() video: Video |
16 | @Input() ownerDisplayType: OwnerDisplayType = 'account' | ||
17 | |||
18 | private ownerDisplayTypeChosen: 'account' | 'videoChannel' | ||
14 | 19 | ||
15 | constructor (private serverService: ServerService) { } | 20 | constructor (private serverService: ServerService) { } |
16 | 21 | ||
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 | |||
17 | isVideoBlur () { | 40 | isVideoBlur () { |
18 | return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) | 41 | return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) |
19 | } | 42 | } |
43 | |||
44 | displayOwnerAccount () { | ||
45 | return this.ownerDisplayTypeChosen === 'account' | ||
46 | } | ||
47 | |||
48 | displayOwnerVideoChannel () { | ||
49 | return this.ownerDisplayTypeChosen === 'videoChannel' | ||
50 | } | ||
20 | } | 51 | } |