Fix NSFW policy on account/channel videos

This commit is contained in:
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 { first, tap } from 'rxjs/operators'
import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
@ -16,6 +16,7 @@ import { VideoFilter } from '@shared/models'
export class AccountSearchComponent extends AbstractVideoList implements OnInit, OnDestroy { export class AccountSearchComponent extends AbstractVideoList implements OnInit, OnDestroy {
titlePage: string titlePage: string
loadOnInit = false loadOnInit = false
loadUserVideoPreferences = true
search = '' search = ''
filter: VideoFilter = null filter: VideoFilter = null
@ -46,13 +47,13 @@ export class AccountSearchComponent extends AbstractVideoList implements OnInit,
this.enableAllFilterIfPossible() this.enableAllFilterIfPossible()
// Parent get the account for us // Parent get the account for us
this.accountSub = this.accountService.accountLoaded this.accountSub = forkJoin([
.pipe(first()) this.accountService.accountLoaded.pipe(first()),
.subscribe(account => { this.onUserLoadedSubject.pipe(first())
]).subscribe(([ account ]) => {
this.account = account this.account = account
this.reloadVideos() this.reloadVideos()
this.generateSyndicationList()
}) })
} }

View File

@ -1,4 +1,4 @@
import { Subscription } from 'rxjs' import { forkJoin, Subscription } from 'rxjs'
import { first, tap } from 'rxjs/operators' import { first, tap } from 'rxjs/operators'
import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
@ -18,6 +18,7 @@ import { VideoFilter } from '@shared/models'
export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { export class AccountVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
titlePage: string titlePage: string
loadOnInit = false loadOnInit = false
loadUserVideoPreferences = true
filter: VideoFilter = null filter: VideoFilter = null
@ -47,9 +48,10 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit,
this.enableAllFilterIfPossible() this.enableAllFilterIfPossible()
// Parent get the account for us // Parent get the account for us
this.accountSub = this.accountService.accountLoaded this.accountSub = forkJoin([
.pipe(first()) this.accountService.accountLoaded.pipe(first()),
.subscribe(account => { this.onUserLoadedSubject.pipe(first())
]).subscribe(([ account ]) => {
this.account = account this.account = account
this.reloadVideos() this.reloadVideos()

View File

@ -1,4 +1,4 @@
import { Subscription } from 'rxjs' import { forkJoin, Subscription } from 'rxjs'
import { first, tap } from 'rxjs/operators' import { first, tap } from 'rxjs/operators'
import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router' import { ActivatedRoute, Router } from '@angular/router'
@ -18,6 +18,7 @@ import { VideoFilter } from '@shared/models'
export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
titlePage: string titlePage: string
loadOnInit = false loadOnInit = false
loadUserVideoPreferences = true
filter: VideoFilter = null filter: VideoFilter = null
@ -53,9 +54,10 @@ export class VideoChannelVideosComponent extends AbstractVideoList implements On
this.enableAllFilterIfPossible() this.enableAllFilterIfPossible()
// Parent get the video channel for us // Parent get the video channel for us
this.videoChannelSub = this.videoChannelService.videoChannelLoaded this.videoChannelSub = forkJoin([
.pipe(first()) this.videoChannelService.videoChannelLoaded.pipe(first()),
.subscribe(videoChannel => { this.onUserLoadedSubject.pipe(first())
]).subscribe(([ videoChannel ]) => {
this.videoChannel = videoChannel this.videoChannel = videoChannel
this.reloadVideos() this.reloadVideos()

View File

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

View File

@ -17,7 +17,7 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On
sort = '-publishedAt' as VideoSortField sort = '-publishedAt' as VideoSortField
filter: VideoFilter = 'local' filter: VideoFilter = 'local'
useUserVideoPreferences = true loadUserVideoPreferences = true
constructor ( constructor (
protected router: Router, protected router: Router,

View File

@ -17,7 +17,7 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
sort: VideoSortField = '-publishedAt' sort: VideoSortField = '-publishedAt'
groupByDate = true groupByDate = true
useUserVideoPreferences = true loadUserVideoPreferences = true
constructor ( constructor (
protected route: ActivatedRoute, 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 { debounceTime, switchMap, tap } from 'rxjs/operators'
import { import {
AfterContentInit, AfterContentInit,
@ -63,7 +63,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
syndicationItems: Syndication[] = [] syndicationItems: Syndication[] = []
loadOnInit = true loadOnInit = true
useUserVideoPreferences = false loadUserVideoPreferences = false
ownerDisplayType: OwnerDisplayType = 'account' ownerDisplayType: OwnerDisplayType = 'account'
displayModerationBlock = false displayModerationBlock = false
titleTooltip: string titleTooltip: string
@ -98,6 +99,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
userMiniature: User userMiniature: User
protected onUserLoadedSubject = new ReplaySubject<void>(1)
protected serverConfig: ServerConfig protected serverConfig: ServerConfig
protected abstract notifier: Notifier protected abstract notifier: Notifier
@ -149,10 +152,11 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
this.calcPageSizes() this.calcPageSizes()
const loadUserObservable = this.loadUserAndSettings() const loadUserObservable = this.loadUserAndSettings()
loadUserObservable.subscribe(() => {
this.onUserLoadedSubject.next()
if (this.loadOnInit === true) { if (this.loadOnInit === true) this.loadMoreVideos()
loadUserObservable.subscribe(() => this.loadMoreVideos()) })
}
this.userService.listenAnonymousUpdate() this.userService.listenAnonymousUpdate()
.pipe(switchMap(() => this.loadUserAndSettings())) .pipe(switchMap(() => this.loadUserAndSettings()))
@ -374,7 +378,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
.pipe(tap(user => { .pipe(tap(user => {
this.userMiniature = user this.userMiniature = user
if (!this.useUserVideoPreferences) return if (!this.loadUserVideoPreferences) return
this.languageOneOf = user.videoLanguages this.languageOneOf = user.videoLanguages
this.nsfwPolicy = user.nsfwPolicy this.nsfwPolicy = user.nsfwPolicy