Fix NSFW policy on account/channel videos

pull/3759/head
Chocobozzz 2021-02-19 13:47:37 +01:00
parent 300cb723eb
commit 07f81d9dee
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
7 changed files with 42 additions and 33 deletions

View File

@ -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.accountSub = forkJoin([
this.accountService.accountLoaded.pipe(first()),
this.onUserLoadedSubject.pipe(first())
]).subscribe(([ account ]) => {
this.account = account
this.reloadVideos()
this.generateSyndicationList()
})
this.reloadVideos()
})
}
ngOnDestroy () {

View File

@ -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 () {

View File

@ -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.videoChannelSub = forkJoin([
this.videoChannelService.videoChannelLoaded.pipe(first()),
this.onUserLoadedSubject.pipe(first())
]).subscribe(([ videoChannel ]) => {
this.videoChannel = videoChannel
this.reloadVideos()
this.generateSyndicationList()
})
this.reloadVideos()
this.generateSyndicationList()
})
}
ngOnDestroy () {

View File

@ -19,7 +19,7 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
titlePage: string
defaultSort: VideoSortField = '-trending'
useUserVideoPreferences = true
loadUserVideoPreferences = true
private algorithmChangeSub: Subscription

View File

@ -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,

View File

@ -17,7 +17,7 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
sort: VideoSortField = '-publishedAt'
groupByDate = true
useUserVideoPreferences = true
loadUserVideoPreferences = true
constructor (
protected route: ActivatedRoute,

View File

@ -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