From 3193ac2c3b0209b87c1347032f7bd21ea651d8e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Jul 2023 15:32:22 +0200 Subject: Refactor a little bit nsfwPolicyToParam --- .../peertube-custom-tags/channel-miniature-markup.component.ts | 4 +++- client/src/app/shared/shared-main/video/video.service.ts | 7 +------ 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts index df7cc95a7..4f00eabd3 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts @@ -84,7 +84,9 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O return this.userService.getAnonymousOrLoggedUser() .pipe( map(user => user.nsfwPolicy), - switchMap(nsfwPolicy => this.videoService.getVideoChannelVideos({ ...videoOptions, nsfwPolicy })) + switchMap(nsfwPolicy => { + return this.videoService.getVideoChannelVideos({ ...videoOptions, nsfw: this.videoService.nsfwPolicyToParam(nsfwPolicy) }) + }) ) } } diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index cd0a300e2..a980c2dcf 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -47,9 +47,6 @@ export type CommonVideoParams = { privacyOneOf?: VideoPrivacy[] isLive?: boolean skipCount?: boolean - - // FIXME: remove? - nsfwPolicy?: NSFWPolicyType nsfw?: BooleanBothQuery } @@ -499,7 +496,7 @@ export class VideoService { throw new Error('No highest privacy available') } - nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType) { + nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType): BooleanBothQuery { return nsfwPolicy === 'do_not_list' ? 'false' : 'both' @@ -534,7 +531,6 @@ export class VideoService { languageOneOf, privacyOneOf, skipCount, - nsfwPolicy, isLive, nsfw } = options @@ -551,7 +547,6 @@ export class VideoService { if (include !== undefined) newParams = newParams.set('include', include) if (isLive !== undefined) newParams = newParams.set('isLive', isLive) if (nsfw !== undefined) newParams = newParams.set('nsfw', nsfw) - if (nsfwPolicy !== undefined) newParams = newParams.set('nsfw', this.nsfwPolicyToParam(nsfwPolicy)) if (languageOneOf !== undefined) newParams = this.restService.addArrayParams(newParams, 'languageOneOf', languageOneOf) if (categoryOneOf !== undefined) newParams = this.restService.addArrayParams(newParams, 'categoryOneOf', categoryOneOf) if (privacyOneOf !== undefined) newParams = this.restService.addArrayParams(newParams, 'privacyOneOf', privacyOneOf) -- cgit v1.2.3