diff options
Diffstat (limited to 'client/src/app/shared/video')
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.html | 4 | ||||
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.ts | 7 | ||||
-rw-r--r-- | client/src/app/shared/video/video.model.ts | 13 |
3 files changed, 17 insertions, 7 deletions
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html index f28e9b8d9..233432142 100644 --- a/client/src/app/shared/video/video-miniature.component.html +++ b/client/src/app/shared/video/video-miniature.component.html | |||
@@ -1,11 +1,11 @@ | |||
1 | <div class="video-miniature"> | 1 | <div class="video-miniature"> |
2 | <my-video-thumbnail [video]="video" [nsfw]="isVideoNSFWForThisUser()"></my-video-thumbnail> | 2 | <my-video-thumbnail [video]="video" [nsfw]="isVideoBlur()"></my-video-thumbnail> |
3 | 3 | ||
4 | <div class="video-miniature-information"> | 4 | <div class="video-miniature-information"> |
5 | <span class="video-miniature-name"> | 5 | <span class="video-miniature-name"> |
6 | <a | 6 | <a |
7 | class="video-miniature-name" | 7 | class="video-miniature-name" |
8 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoNSFWForThisUser() }" | 8 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur() }" |
9 | > | 9 | > |
10 | {{ video.name }} | 10 | {{ video.name }} |
11 | </a> | 11 | </a> |
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts index 4d79a74bb..d3f6dc1f6 100644 --- a/client/src/app/shared/video/video-miniature.component.ts +++ b/client/src/app/shared/video/video-miniature.component.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { Component, Input } from '@angular/core' | 1 | import { Component, Input } 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 | 5 | ||
5 | @Component({ | 6 | @Component({ |
6 | selector: 'my-video-miniature', | 7 | selector: 'my-video-miniature', |
@@ -11,7 +12,9 @@ export class VideoMiniatureComponent { | |||
11 | @Input() user: User | 12 | @Input() user: User |
12 | @Input() video: Video | 13 | @Input() video: Video |
13 | 14 | ||
14 | isVideoNSFWForThisUser () { | 15 | constructor (private serverService: ServerService) { } |
15 | return this.video.isVideoNSFWForUser(this.user) | 16 | |
17 | isVideoBlur () { | ||
18 | return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) | ||
16 | } | 19 | } |
17 | } | 20 | } |
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index 0c02cbcb9..adc248a1e 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts | |||
@@ -4,6 +4,7 @@ import { Video as VideoServerModel } from '../../../../../shared' | |||
4 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | 4 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
5 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' | 5 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' |
6 | import { getAbsoluteAPIUrl } from '../misc/utils' | 6 | import { getAbsoluteAPIUrl } from '../misc/utils' |
7 | import { ServerConfig } from '../../../../../shared/models' | ||
7 | 8 | ||
8 | export class Video implements VideoServerModel { | 9 | export class Video implements VideoServerModel { |
9 | by: string | 10 | by: string |
@@ -83,8 +84,14 @@ export class Video implements VideoServerModel { | |||
83 | this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host) | 84 | this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host) |
84 | } | 85 | } |
85 | 86 | ||
86 | isVideoNSFWForUser (user: User) { | 87 | isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { |
87 | // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos... | 88 | // Video is not NSFW, skip |
88 | return (this.nsfw && (!user || user.displayNSFW === false)) | 89 | if (this.nsfw === false) return false |
90 | |||
91 | // Return user setting if logged in | ||
92 | if (user) return user.nsfwPolicy !== 'display' | ||
93 | |||
94 | // Return default instance config | ||
95 | return serverConfig.instance.defaultNSFWPolicy !== 'display' | ||
89 | } | 96 | } |
90 | } | 97 | } |