aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video/video.service.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-02-28 13:52:21 +0100
committerGitHub <noreply@github.com>2020-02-28 13:52:21 +0100
commitd3217560a611b94f888ecf3de93b428a7521d4de (patch)
tree26fc984f351afb994dc13c94e138476ded50c76a /client/src/app/shared/video/video.service.ts
parent64645512b08875c18ebdc009a550cdfa69def955 (diff)
downloadPeerTube-d3217560a611b94f888ecf3de93b428a7521d4de.tar.gz
PeerTube-d3217560a611b94f888ecf3de93b428a7521d4de.tar.zst
PeerTube-d3217560a611b94f888ecf3de93b428a7521d4de.zip
Add visitor settings, rework logged-in dropdown (#2514)
* Add visitor settings, rework logged-in dropdown * Make user dropdown P2P switch functional * Fix lint * Fix unnecessary notification when user logs out * Simplify visitor settings code and remove unnecessary icons * Catch parsing errors and reindent menu styles
Diffstat (limited to 'client/src/app/shared/video/video.service.ts')
-rw-r--r--client/src/app/shared/video/video.service.ts23
1 files changed, 20 insertions, 3 deletions
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index 996202154..a51b9cab9 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -27,10 +27,11 @@ import { objectToFormData } from '@app/shared/misc/utils'
27import { Account } from '@app/shared/account/account.model' 27import { Account } from '@app/shared/account/account.model'
28import { AccountService } from '@app/shared/account/account.service' 28import { AccountService } from '@app/shared/account/account.service'
29import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 29import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
30import { ServerService } from '@app/core' 30import { ServerService, AuthService } from '@app/core'
31import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service' 31import { UserSubscriptionService } from '@app/shared/user-subscription/user-subscription.service'
32import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 32import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
33import { I18n } from '@ngx-translate/i18n-polyfill' 33import { I18n } from '@ngx-translate/i18n-polyfill'
34import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
34 35
35export interface VideosProvider { 36export interface VideosProvider {
36 getVideos (parameters: { 37 getVideos (parameters: {
@@ -49,6 +50,8 @@ export class VideoService implements VideosProvider {
49 50
50 constructor ( 51 constructor (
51 private authHttp: HttpClient, 52 private authHttp: HttpClient,
53 private authService: AuthService,
54 private userService: UserService,
52 private restExtractor: RestExtractor, 55 private restExtractor: RestExtractor,
53 private restService: RestService, 56 private restService: RestService,
54 private serverService: ServerService, 57 private serverService: ServerService,
@@ -199,9 +202,10 @@ export class VideoService implements VideosProvider {
199 filter?: VideoFilter, 202 filter?: VideoFilter,
200 categoryOneOf?: number, 203 categoryOneOf?: number,
201 languageOneOf?: string[], 204 languageOneOf?: string[],
202 skipCount?: boolean 205 skipCount?: boolean,
206 nsfw?: boolean
203 }): Observable<ResultList<Video>> { 207 }): Observable<ResultList<Video>> {
204 const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount } = parameters 208 const { videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount, nsfw } = parameters
205 209
206 const pagination = this.restService.componentPaginationToRestPagination(videoPagination) 210 const pagination = this.restService.componentPaginationToRestPagination(videoPagination)
207 211
@@ -212,6 +216,15 @@ export class VideoService implements VideosProvider {
212 if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '') 216 if (categoryOneOf) params = params.set('categoryOneOf', categoryOneOf + '')
213 if (skipCount) params = params.set('skipCount', skipCount + '') 217 if (skipCount) params = params.set('skipCount', skipCount + '')
214 218
219 if (nsfw) {
220 params = params.set('nsfw', nsfw + '')
221 } else {
222 const nsfwPolicy = this.authService.isLoggedIn()
223 ? this.authService.getUser().nsfwPolicy
224 : this.userService.getAnonymousUser().nsfwPolicy
225 if (this.nsfwPolicyToFilter(nsfwPolicy)) params.set('nsfw', 'false')
226 }
227
215 if (languageOneOf) { 228 if (languageOneOf) {
216 for (const l of languageOneOf) { 229 for (const l of languageOneOf) {
217 params = params.append('languageOneOf[]', l) 230 params = params.append('languageOneOf[]', l)
@@ -368,4 +381,8 @@ export class VideoService implements VideosProvider {
368 catchError(err => this.restExtractor.handleError(err)) 381 catchError(err => this.restExtractor.handleError(err))
369 ) 382 )
370 } 383 }
384
385 private nsfwPolicyToFilter (policy: NSFWPolicyType) {
386 return policy === 'do_not_list'
387 }
371} 388}