diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-19 13:47:37 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-19 13:47:37 +0100 |
commit | 07f81d9deedf4921b8518c2d2b16043167b4c5d5 (patch) | |
tree | e333622a6686d637612a2f552aa0c64503163fe5 /client | |
parent | 300cb723eb9bd219e6d381c57a8a6a860563bbbb (diff) | |
download | PeerTube-07f81d9deedf4921b8518c2d2b16043167b4c5d5.tar.gz PeerTube-07f81d9deedf4921b8518c2d2b16043167b4c5d5.tar.zst PeerTube-07f81d9deedf4921b8518c2d2b16043167b4c5d5.zip |
Fix NSFW policy on account/channel videos
Diffstat (limited to 'client')
7 files changed, 44 insertions, 35 deletions
diff --git a/client/src/app/+accounts/account-search/account-search.component.ts b/client/src/app/+accounts/account-search/account-search.component.ts index 378aa78c4..dda4bf0c7 100644 --- a/client/src/app/+accounts/account-search/account-search.component.ts +++ b/client/src/app/+accounts/account-search/account-search.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Subscription } from 'rxjs' | 1 | import { forkJoin, Subscription } from 'rxjs' |
2 | import { first, tap } from 'rxjs/operators' | 2 | import { first, tap } from 'rxjs/operators' |
3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' | 3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' |
4 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ActivatedRoute, Router } from '@angular/router' |
@@ -16,6 +16,7 @@ import { VideoFilter } from '@shared/models' | |||
16 | export class AccountSearchComponent extends AbstractVideoList implements OnInit, OnDestroy { | 16 | export class AccountSearchComponent extends AbstractVideoList implements OnInit, OnDestroy { |
17 | titlePage: string | 17 | titlePage: string |
18 | loadOnInit = false | 18 | loadOnInit = false |
19 | loadUserVideoPreferences = true | ||
19 | 20 | ||
20 | search = '' | 21 | search = '' |
21 | filter: VideoFilter = null | 22 | filter: VideoFilter = null |
@@ -46,14 +47,14 @@ export class AccountSearchComponent extends AbstractVideoList implements OnInit, | |||
46 | this.enableAllFilterIfPossible() | 47 | this.enableAllFilterIfPossible() |
47 | 48 | ||
48 | // Parent get the account for us | 49 | // Parent get the account for us |
49 | this.accountSub = this.accountService.accountLoaded | 50 | this.accountSub = forkJoin([ |
50 | .pipe(first()) | 51 | this.accountService.accountLoaded.pipe(first()), |
51 | .subscribe(account => { | 52 | this.onUserLoadedSubject.pipe(first()) |
52 | this.account = account | 53 | ]).subscribe(([ account ]) => { |
53 | 54 | this.account = account | |
54 | this.reloadVideos() | 55 | |
55 | this.generateSyndicationList() | 56 | this.reloadVideos() |
56 | }) | 57 | }) |
57 | } | 58 | } |
58 | 59 | ||
59 | ngOnDestroy () { | 60 | ngOnDestroy () { |
diff --git a/client/src/app/+accounts/account-videos/account-videos.component.ts b/client/src/app/+accounts/account-videos/account-videos.component.ts index da3903d2c..484d60e25 100644 --- a/client/src/app/+accounts/account-videos/account-videos.component.ts +++ b/client/src/app/+accounts/account-videos/account-videos.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Subscription } from 'rxjs' | 1 | import { forkJoin, Subscription } from 'rxjs' |
2 | import { first, tap } from 'rxjs/operators' | 2 | import { first, tap } from 'rxjs/operators' |
3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' | 3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' |
4 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ActivatedRoute, Router } from '@angular/router' |
@@ -18,6 +18,7 @@ import { VideoFilter } from '@shared/models' | |||
18 | export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { | 18 | export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { |
19 | titlePage: string | 19 | titlePage: string |
20 | loadOnInit = false | 20 | loadOnInit = false |
21 | loadUserVideoPreferences = true | ||
21 | 22 | ||
22 | filter: VideoFilter = null | 23 | filter: VideoFilter = null |
23 | 24 | ||
@@ -47,14 +48,15 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit, | |||
47 | this.enableAllFilterIfPossible() | 48 | this.enableAllFilterIfPossible() |
48 | 49 | ||
49 | // Parent get the account for us | 50 | // Parent get the account for us |
50 | this.accountSub = this.accountService.accountLoaded | 51 | this.accountSub = forkJoin([ |
51 | .pipe(first()) | 52 | this.accountService.accountLoaded.pipe(first()), |
52 | .subscribe(account => { | 53 | this.onUserLoadedSubject.pipe(first()) |
53 | this.account = account | 54 | ]).subscribe(([ account ]) => { |
55 | this.account = account | ||
54 | 56 | ||
55 | this.reloadVideos() | 57 | this.reloadVideos() |
56 | this.generateSyndicationList() | 58 | this.generateSyndicationList() |
57 | }) | 59 | }) |
58 | } | 60 | } |
59 | 61 | ||
60 | ngOnDestroy () { | 62 | ngOnDestroy () { |
diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts index a49fd0d5d..803651505 100644 --- a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts +++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Subscription } from 'rxjs' | 1 | import { forkJoin, Subscription } from 'rxjs' |
2 | import { first, tap } from 'rxjs/operators' | 2 | import { first, tap } from 'rxjs/operators' |
3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' | 3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' |
4 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ActivatedRoute, Router } from '@angular/router' |
@@ -18,6 +18,7 @@ import { VideoFilter } from '@shared/models' | |||
18 | export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { | 18 | export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { |
19 | titlePage: string | 19 | titlePage: string |
20 | loadOnInit = false | 20 | loadOnInit = false |
21 | loadUserVideoPreferences = true | ||
21 | 22 | ||
22 | filter: VideoFilter = null | 23 | filter: VideoFilter = null |
23 | 24 | ||
@@ -53,14 +54,15 @@ export class VideoChannelVideosComponent extends AbstractVideoList implements On | |||
53 | this.enableAllFilterIfPossible() | 54 | this.enableAllFilterIfPossible() |
54 | 55 | ||
55 | // Parent get the video channel for us | 56 | // Parent get the video channel for us |
56 | this.videoChannelSub = this.videoChannelService.videoChannelLoaded | 57 | this.videoChannelSub = forkJoin([ |
57 | .pipe(first()) | 58 | this.videoChannelService.videoChannelLoaded.pipe(first()), |
58 | .subscribe(videoChannel => { | 59 | this.onUserLoadedSubject.pipe(first()) |
59 | this.videoChannel = videoChannel | 60 | ]).subscribe(([ videoChannel ]) => { |
60 | 61 | this.videoChannel = videoChannel | |
61 | this.reloadVideos() | 62 | |
62 | this.generateSyndicationList() | 63 | this.reloadVideos() |
63 | }) | 64 | this.generateSyndicationList() |
65 | }) | ||
64 | } | 66 | } |
65 | 67 | ||
66 | ngOnDestroy () { | 68 | ngOnDestroy () { |
diff --git a/client/src/app/+videos/video-list/trending/video-trending.component.ts b/client/src/app/+videos/video-list/trending/video-trending.component.ts index 6128c4acd..c11f0da9d 100644 --- a/client/src/app/+videos/video-list/trending/video-trending.component.ts +++ b/client/src/app/+videos/video-list/trending/video-trending.component.ts | |||
@@ -19,7 +19,7 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit, | |||
19 | titlePage: string | 19 | titlePage: string |
20 | defaultSort: VideoSortField = '-trending' | 20 | defaultSort: VideoSortField = '-trending' |
21 | 21 | ||
22 | useUserVideoPreferences = true | 22 | loadUserVideoPreferences = true |
23 | 23 | ||
24 | private algorithmChangeSub: Subscription | 24 | private algorithmChangeSub: Subscription |
25 | 25 | ||
diff --git a/client/src/app/+videos/video-list/video-local.component.ts b/client/src/app/+videos/video-list/video-local.component.ts index af7eecff4..4be8cd6b5 100644 --- a/client/src/app/+videos/video-list/video-local.component.ts +++ b/client/src/app/+videos/video-list/video-local.component.ts | |||
@@ -17,7 +17,7 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On | |||
17 | sort = '-publishedAt' as VideoSortField | 17 | sort = '-publishedAt' as VideoSortField |
18 | filter: VideoFilter = 'local' | 18 | filter: VideoFilter = 'local' |
19 | 19 | ||
20 | useUserVideoPreferences = true | 20 | loadUserVideoPreferences = true |
21 | 21 | ||
22 | constructor ( | 22 | constructor ( |
23 | protected router: Router, | 23 | protected router: Router, |
diff --git a/client/src/app/+videos/video-list/video-recently-added.component.ts b/client/src/app/+videos/video-list/video-recently-added.component.ts index 2f4908074..506f92d25 100644 --- a/client/src/app/+videos/video-list/video-recently-added.component.ts +++ b/client/src/app/+videos/video-list/video-recently-added.component.ts | |||
@@ -17,7 +17,7 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On | |||
17 | sort: VideoSortField = '-publishedAt' | 17 | sort: VideoSortField = '-publishedAt' |
18 | groupByDate = true | 18 | groupByDate = true |
19 | 19 | ||
20 | useUserVideoPreferences = true | 20 | loadUserVideoPreferences = true |
21 | 21 | ||
22 | constructor ( | 22 | constructor ( |
23 | protected route: ActivatedRoute, | 23 | protected route: ActivatedRoute, |
diff --git a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts index 5361f6d6c..f8abc1656 100644 --- a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts +++ b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { fromEvent, Observable, Subject, Subscription } from 'rxjs' | 1 | import { fromEvent, Observable, ReplaySubject, Subject, Subscription } from 'rxjs' |
2 | import { debounceTime, switchMap, tap } from 'rxjs/operators' | 2 | import { debounceTime, switchMap, tap } from 'rxjs/operators' |
3 | import { | 3 | import { |
4 | AfterContentInit, | 4 | AfterContentInit, |
@@ -63,7 +63,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte | |||
63 | syndicationItems: Syndication[] = [] | 63 | syndicationItems: Syndication[] = [] |
64 | 64 | ||
65 | loadOnInit = true | 65 | loadOnInit = true |
66 | useUserVideoPreferences = false | 66 | loadUserVideoPreferences = false |
67 | |||
67 | ownerDisplayType: OwnerDisplayType = 'account' | 68 | ownerDisplayType: OwnerDisplayType = 'account' |
68 | displayModerationBlock = false | 69 | displayModerationBlock = false |
69 | titleTooltip: string | 70 | titleTooltip: string |
@@ -98,6 +99,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte | |||
98 | 99 | ||
99 | userMiniature: User | 100 | userMiniature: User |
100 | 101 | ||
102 | protected onUserLoadedSubject = new ReplaySubject<void>(1) | ||
103 | |||
101 | protected serverConfig: ServerConfig | 104 | protected serverConfig: ServerConfig |
102 | 105 | ||
103 | protected abstract notifier: Notifier | 106 | protected abstract notifier: Notifier |
@@ -149,10 +152,11 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte | |||
149 | this.calcPageSizes() | 152 | this.calcPageSizes() |
150 | 153 | ||
151 | const loadUserObservable = this.loadUserAndSettings() | 154 | const loadUserObservable = this.loadUserAndSettings() |
155 | loadUserObservable.subscribe(() => { | ||
156 | this.onUserLoadedSubject.next() | ||
152 | 157 | ||
153 | if (this.loadOnInit === true) { | 158 | if (this.loadOnInit === true) this.loadMoreVideos() |
154 | loadUserObservable.subscribe(() => this.loadMoreVideos()) | 159 | }) |
155 | } | ||
156 | 160 | ||
157 | this.userService.listenAnonymousUpdate() | 161 | this.userService.listenAnonymousUpdate() |
158 | .pipe(switchMap(() => this.loadUserAndSettings())) | 162 | .pipe(switchMap(() => this.loadUserAndSettings())) |
@@ -374,7 +378,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte | |||
374 | .pipe(tap(user => { | 378 | .pipe(tap(user => { |
375 | this.userMiniature = user | 379 | this.userMiniature = user |
376 | 380 | ||
377 | if (!this.useUserVideoPreferences) return | 381 | if (!this.loadUserVideoPreferences) return |
378 | 382 | ||
379 | this.languageOneOf = user.videoLanguages | 383 | this.languageOneOf = user.videoLanguages |
380 | this.nsfwPolicy = user.nsfwPolicy | 384 | this.nsfwPolicy = user.nsfwPolicy |