Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix NSFW policy on account/channel videos

Chocobozzz07f81d9deedf
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 378aa78c45..dda4bf0c76 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 @@
-import { Subscription } from 'rxjs'
+import { forkJoin, Subscription } from 'rxjs'
import { first, tap } from 'rxjs/operators'
import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
@@ -16,6 +16,7 @@ import { VideoFilter } from '@shared/models'
export class AccountSearchComponent extends AbstractVideoList implements OnInit, OnDestroy {
titlePage: string
loadOnInit = false
+ loadUserVideoPreferences = true
search = ''
filter: VideoFilter = null
@@ -46,14 +47,14 @@ export class AccountSearchComponent extends AbstractVideoList implements OnInit,
this.enableAllFilterIfPossible()
// Parent get the account for us
- this.accountSub = this.accountService.accountLoaded
- .pipe(first())
- .subscribe(account => {
- this.account = account
-
- this.reloadVideos()
- this.generateSyndicationList()
- })
+ this.accountSub = forkJoin([
+ this.accountService.accountLoaded.pipe(first()),
+ this.onUserLoadedSubject.pipe(first())
+ ]).subscribe(([ account ]) => {
+ this.account = account
+
+ this.reloadVideos()
+ })
}
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 da3903d2c7..484d60e25d 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 @@
-import { Subscription } from 'rxjs'
+import { forkJoin, Subscription } from 'rxjs'
import { first, tap } from 'rxjs/operators'
import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
@@ -18,6 +18,7 @@ import { VideoFilter } from '@shared/models'
export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
titlePage: string
loadOnInit = false
+ loadUserVideoPreferences = true
filter: VideoFilter = null
@@ -47,14 +48,15 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
this.enableAllFilterIfPossible()
// Parent get the account for us
- this.accountSub = this.accountService.accountLoaded
- .pipe(first())
- .subscribe(account => {
- this.account = account
+ this.accountSub = forkJoin([
+ this.accountService.accountLoaded.pipe(first()),
+ this.onUserLoadedSubject.pipe(first())
+ ]).subscribe(([ account ]) => {
+ this.account = account
- this.reloadVideos()
- this.generateSyndicationList()
- })
+ this.reloadVideos()
+ this.generateSyndicationList()
+ })
}
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 a49fd0d5dd..8036515058 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 @@
-import { Subscription } from 'rxjs'
+import { forkJoin, Subscription } from 'rxjs'
import { first, tap } from 'rxjs/operators'
import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
@@ -18,6 +18,7 @@ import { VideoFilter } from '@shared/models'
export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
titlePage: string
loadOnInit = false
+ loadUserVideoPreferences = true
filter: VideoFilter = null
@@ -53,14 +54,15 @@ export class VideoChannelVideosComponent extends AbstractVideoList implements On
this.enableAllFilterIfPossible()
// Parent get the video channel for us
- this.videoChannelSub = this.videoChannelService.videoChannelLoaded
- .pipe(first())
- .subscribe(videoChannel => {
- this.videoChannel = videoChannel
-
- this.reloadVideos()
- this.generateSyndicationList()
- })
+ this.videoChannelSub = forkJoin([
+ this.videoChannelService.videoChannelLoaded.pipe(first()),
+ this.onUserLoadedSubject.pipe(first())
+ ]).subscribe(([ videoChannel ]) => {
+ this.videoChannel = videoChannel
+
+ this.reloadVideos()
+ this.generateSyndicationList()
+ })
}
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 6128c4acd5..c11f0da9d8 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,
titlePage: string
defaultSort: VideoSortField = '-trending'
- useUserVideoPreferences = true
+ loadUserVideoPreferences = true
private algorithmChangeSub: Subscription
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 af7eecff44..4be8cd6b5d 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
sort = '-publishedAt' as VideoSortField
filter: VideoFilter = 'local'
- useUserVideoPreferences = true
+ loadUserVideoPreferences = true
constructor (
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 2f4908074d..506f92d25f 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
sort: VideoSortField = '-publishedAt'
groupByDate = true
- useUserVideoPreferences = true
+ loadUserVideoPreferences = true
constructor (
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 5361f6d6cf..f8abc1656d 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 @@
-import { fromEvent, Observable, Subject, Subscription } from 'rxjs'
+import { fromEvent, Observable, ReplaySubject, Subject, Subscription } from 'rxjs'
import { debounceTime, switchMap, tap } from 'rxjs/operators'
import {
AfterContentInit,
@@ -63,7 +63,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
syndicationItems: Syndication[] = []
loadOnInit = true
- useUserVideoPreferences = false
+ loadUserVideoPreferences = false
+
ownerDisplayType: OwnerDisplayType = 'account'
displayModerationBlock = false
titleTooltip: string
@@ -98,6 +99,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
userMiniature: User
+ protected onUserLoadedSubject = new ReplaySubject<void>(1)
+
protected serverConfig: ServerConfig
protected abstract notifier: Notifier
@@ -149,10 +152,11 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
this.calcPageSizes()
const loadUserObservable = this.loadUserAndSettings()
+ loadUserObservable.subscribe(() => {
+ this.onUserLoadedSubject.next()
- if (this.loadOnInit === true) {
- loadUserObservable.subscribe(() => this.loadMoreVideos())
- }
+ if (this.loadOnInit === true) this.loadMoreVideos()
+ })
this.userService.listenAnonymousUpdate()
.pipe(switchMap(() => this.loadUserAndSettings()))
@@ -374,7 +378,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
.pipe(tap(user => {
this.userMiniature = user
- if (!this.useUserVideoPreferences) return
+ if (!this.loadUserVideoPreferences) return
this.languageOneOf = user.videoLanguages
this.nsfwPolicy = user.nsfwPolicy