allow public video privacy to be deleted in the web client

pull/4176/head
Rigel Kent 2021-06-05 11:05:25 +02:00 committed by Chocobozzz
parent 27bc958674
commit 2951065162
7 changed files with 15 additions and 17 deletions

View File

@ -184,7 +184,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
this.serverService.getVideoPrivacies()
.subscribe(privacies => {
this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies)
this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies
if (this.schedulePublicationPossible) {
this.videoPrivacies.push({
id: this.SPECIAL_SCHEDULED_PRIVACY,

View File

@ -30,8 +30,6 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
videoUUID: string
error: string
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
constructor (
protected formValidatorService: FormValidatorService,
protected loadingBar: LoadingBarService,

View File

@ -32,8 +32,6 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
video: VideoEdit
error: string
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
constructor (
protected formValidatorService: FormValidatorService,
protected loadingBar: LoadingBarService,

View File

@ -31,8 +31,6 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
video: VideoEdit
error: string
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
constructor (
protected formValidatorService: FormValidatorService,
protected loadingBar: LoadingBarService,

View File

@ -20,7 +20,6 @@ export abstract class VideoSend extends FormReactive implements OnInit {
abstract firstStepDone: EventEmitter<string>
abstract firstStepError: EventEmitter<void>
protected abstract readonly DEFAULT_VIDEO_PRIVACY: VideoPrivacy
protected loadingBar: LoadingBarService
protected notifier: Notifier
@ -46,9 +45,10 @@ export abstract class VideoSend extends FormReactive implements OnInit {
this.serverService.getVideoPrivacies()
.subscribe(
privacies => {
this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies)
const { videoPrivacies, defaultPrivacyId } = this.videoService.explainedPrivacyLabels(privacies)
this.firstStepPrivacyId = this.DEFAULT_VIDEO_PRIVACY
this.videoPrivacies = videoPrivacies
this.firstStepPrivacyId = defaultPrivacyId
})
}

View File

@ -46,7 +46,6 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
enableRetryAfterError: boolean
// So that it can be accessed in the template
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
protected readonly BASE_VIDEO_UPLOAD_URL = VideoService.BASE_VIDEO_URL + 'upload-resumable'
private uploadxOptions: UploadxOptions

View File

@ -1,8 +1,8 @@
import { Observable, of, throwError } from 'rxjs'
import { catchError, map, mergeMap, switchMap } from 'rxjs/operators'
import { HttpClient, HttpErrorResponse, HttpParams, HttpRequest } from '@angular/common/http'
import { Observable } from 'rxjs'
import { catchError, map, switchMap } from 'rxjs/operators'
import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService, AuthService } from '@app/core'
import { ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService } from '@app/core'
import { objectToFormData } from '@app/helpers'
import {
FeedFormat,
@ -378,7 +378,7 @@ export class VideoService implements VideosProvider {
)
}
explainedPrivacyLabels (privacies: VideoConstant<VideoPrivacy>[]) {
explainedPrivacyLabels (privacies: VideoConstant<VideoPrivacy>[], defaultPrivacyId = VideoPrivacy.PUBLIC) {
const base = [
{
id: VideoPrivacy.PRIVATE,
@ -398,9 +398,14 @@ export class VideoService implements VideosProvider {
}
]
return base
const videoPrivacies = base
.filter(o => !!privacies.find(p => p.id === o.id)) // filter down to privacies that where in the input
.map(o => ({ ...privacies[o.id - 1], ...o })) // merge the input privacies that contain a label, and extend them with a description
return {
defaultPrivacyId: videoPrivacies.find(p => p.id === defaultPrivacyId)?.id || videoPrivacies[0].id,
videoPrivacies
}
}
nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType) {