aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-09-03 10:27:04 +0200
committerChocobozzz <me@florianbigard.com>2021-09-03 16:35:18 +0200
commit6d210220be0875d63461829d83c6e3a59d05cf7a (patch)
tree60ec5b596ef06295b70ebb553920a39b549e0f13 /client/src/app
parent2ede07153ce0282b116345dfee09bff902355a75 (diff)
downloadPeerTube-6d210220be0875d63461829d83c6e3a59d05cf7a.tar.gz
PeerTube-6d210220be0875d63461829d83c6e3a59d05cf7a.tar.zst
PeerTube-6d210220be0875d63461829d83c6e3a59d05cf7a.zip
Fix NSFW filter and add tests
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/core/users/user.service.ts6
-rw-r--r--client/src/app/shared/shared-video-miniature/video-filters-header.component.ts6
-rw-r--r--client/src/app/shared/shared-video-miniature/video-filters.model.ts2
-rw-r--r--client/src/app/shared/shared-video-miniature/videos-list.component.html2
4 files changed, 8 insertions, 8 deletions
diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts
index be9e66c3c..632361e9b 100644
--- a/client/src/app/core/users/user.service.ts
+++ b/client/src/app/core/users/user.service.ts
@@ -17,6 +17,7 @@ import {
17 UserUpdateMe, 17 UserUpdateMe,
18 UserVideoQuota 18 UserVideoQuota
19} from '@shared/models' 19} from '@shared/models'
20import { ServerService } from '../'
20import { environment } from '../../../environments/environment' 21import { environment } from '../../../environments/environment'
21import { RestExtractor, RestPagination, RestService } from '../rest' 22import { RestExtractor, RestPagination, RestService } from '../rest'
22import { LocalStorageService, SessionStorageService } from '../wrappers/storage.service' 23import { LocalStorageService, SessionStorageService } from '../wrappers/storage.service'
@@ -32,6 +33,7 @@ export class UserService {
32 33
33 constructor ( 34 constructor (
34 private authHttp: HttpClient, 35 private authHttp: HttpClient,
36 private server: ServerService,
35 private authService: AuthService, 37 private authService: AuthService,
36 private restExtractor: RestExtractor, 38 private restExtractor: RestExtractor,
37 private restService: RestService, 39 private restService: RestService,
@@ -298,9 +300,11 @@ export class UserService {
298 console.error('Cannot parse desired video languages from localStorage.', err) 300 console.error('Cannot parse desired video languages from localStorage.', err)
299 } 301 }
300 302
303 const defaultNSFWPolicy = this.server.getHTMLConfig().instance.defaultNSFWPolicy
304
301 return new User({ 305 return new User({
302 // local storage keys 306 // local storage keys
303 nsfwPolicy: this.localStorageService.getItem(UserLocalStorageKeys.NSFW_POLICY), 307 nsfwPolicy: this.localStorageService.getItem(UserLocalStorageKeys.NSFW_POLICY) || defaultNSFWPolicy,
304 webTorrentEnabled: this.localStorageService.getItem(UserLocalStorageKeys.WEBTORRENT_ENABLED) !== 'false', 308 webTorrentEnabled: this.localStorageService.getItem(UserLocalStorageKeys.WEBTORRENT_ENABLED) !== 'false',
305 theme: this.localStorageService.getItem(UserLocalStorageKeys.THEME) || 'instance-default', 309 theme: this.localStorageService.getItem(UserLocalStorageKeys.THEME) || 'instance-default',
306 videoLanguages, 310 videoLanguages,
diff --git a/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts b/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
index 54a7c5dab..2c52e43f7 100644
--- a/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-filters-header.component.ts
@@ -5,7 +5,6 @@ import { FormBuilder, FormGroup } from '@angular/forms'
5import { AuthService } from '@app/core' 5import { AuthService } from '@app/core'
6import { ServerService } from '@app/core/server/server.service' 6import { ServerService } from '@app/core/server/server.service'
7import { UserRight } from '@shared/models' 7import { UserRight } from '@shared/models'
8import { NSFWPolicyType } from '@shared/models/videos'
9import { PeertubeModalService } from '../shared-main' 8import { PeertubeModalService } from '../shared-main'
10import { VideoFilters } from './video-filters.model' 9import { VideoFilters } from './video-filters.model'
11 10
@@ -18,12 +17,7 @@ const logger = debug('peertube:videos:VideoFiltersHeaderComponent')
18}) 17})
19export class VideoFiltersHeaderComponent implements OnInit, OnDestroy { 18export class VideoFiltersHeaderComponent implements OnInit, OnDestroy {
20 @Input() filters: VideoFilters 19 @Input() filters: VideoFilters
21
22 @Input() displayModerationBlock = false 20 @Input() displayModerationBlock = false
23
24 @Input() defaultSort = '-publishedAt'
25 @Input() nsfwPolicy: NSFWPolicyType
26
27 @Input() hideScope = false 21 @Input() hideScope = false
28 22
29 @Output() filtersChanged = new EventEmitter() 23 @Output() filtersChanged = new EventEmitter()
diff --git a/client/src/app/shared/shared-video-miniature/video-filters.model.ts b/client/src/app/shared/shared-video-miniature/video-filters.model.ts
index 920dc826c..f5095b85b 100644
--- a/client/src/app/shared/shared-video-miniature/video-filters.model.ts
+++ b/client/src/app/shared/shared-video-miniature/video-filters.model.ts
@@ -74,6 +74,8 @@ export class VideoFilters {
74 } 74 }
75 75
76 setNSFWPolicy (nsfwPolicy: NSFWPolicyType) { 76 setNSFWPolicy (nsfwPolicy: NSFWPolicyType) {
77 console.log(nsfwPolicy)
78
77 this.updateDefaultNSFW(nsfwPolicy) 79 this.updateDefaultNSFW(nsfwPolicy)
78 } 80 }
79 81
diff --git a/client/src/app/shared/shared-video-miniature/videos-list.component.html b/client/src/app/shared/shared-video-miniature/videos-list.component.html
index 08ed7b94c..67933f177 100644
--- a/client/src/app/shared/shared-video-miniature/videos-list.component.html
+++ b/client/src/app/shared/shared-video-miniature/videos-list.component.html
@@ -34,7 +34,7 @@
34 34
35 <my-video-filters-header 35 <my-video-filters-header
36 *ngIf="displayFilters" [displayModerationBlock]="displayModerationBlock" [hideScope]="hideScopeFilter" 36 *ngIf="displayFilters" [displayModerationBlock]="displayModerationBlock" [hideScope]="hideScopeFilter"
37 [defaultSort]="defaultSort" [filters]="filters" 37 [filters]="filters"
38 (filtersChanged)="onFiltersChanged(true)" 38 (filtersChanged)="onFiltersChanged(true)"
39 ></my-video-filters-header> 39 ></my-video-filters-header>
40 40