From 6d210220be0875d63461829d83c6e3a59d05cf7a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Sep 2021 10:27:04 +0200 Subject: Fix NSFW filter and add tests --- client/src/app/core/users/user.service.ts | 6 +++++- .../shared/shared-video-miniature/video-filters-header.component.ts | 6 ------ client/src/app/shared/shared-video-miniature/video-filters.model.ts | 2 ++ .../app/shared/shared-video-miniature/videos-list.component.html | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'client/src') 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 { UserUpdateMe, UserVideoQuota } from '@shared/models' +import { ServerService } from '../' import { environment } from '../../../environments/environment' import { RestExtractor, RestPagination, RestService } from '../rest' import { LocalStorageService, SessionStorageService } from '../wrappers/storage.service' @@ -32,6 +33,7 @@ export class UserService { constructor ( private authHttp: HttpClient, + private server: ServerService, private authService: AuthService, private restExtractor: RestExtractor, private restService: RestService, @@ -298,9 +300,11 @@ export class UserService { console.error('Cannot parse desired video languages from localStorage.', err) } + const defaultNSFWPolicy = this.server.getHTMLConfig().instance.defaultNSFWPolicy + return new User({ // local storage keys - nsfwPolicy: this.localStorageService.getItem(UserLocalStorageKeys.NSFW_POLICY), + nsfwPolicy: this.localStorageService.getItem(UserLocalStorageKeys.NSFW_POLICY) || defaultNSFWPolicy, webTorrentEnabled: this.localStorageService.getItem(UserLocalStorageKeys.WEBTORRENT_ENABLED) !== 'false', theme: this.localStorageService.getItem(UserLocalStorageKeys.THEME) || 'instance-default', 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' import { AuthService } from '@app/core' import { ServerService } from '@app/core/server/server.service' import { UserRight } from '@shared/models' -import { NSFWPolicyType } from '@shared/models/videos' import { PeertubeModalService } from '../shared-main' import { VideoFilters } from './video-filters.model' @@ -18,12 +17,7 @@ const logger = debug('peertube:videos:VideoFiltersHeaderComponent') }) export class VideoFiltersHeaderComponent implements OnInit, OnDestroy { @Input() filters: VideoFilters - @Input() displayModerationBlock = false - - @Input() defaultSort = '-publishedAt' - @Input() nsfwPolicy: NSFWPolicyType - @Input() hideScope = false @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 { } setNSFWPolicy (nsfwPolicy: NSFWPolicyType) { + console.log(nsfwPolicy) + this.updateDefaultNSFW(nsfwPolicy) } 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 @@ -- cgit v1.2.3