Commit 29510651 authored by Rigel Kent's avatar Rigel Kent Committed by Chocobozzz
Browse files

allow public video privacy to be deleted in the web client

parent 27bc9586
...@@ -184,7 +184,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { ...@@ -184,7 +184,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
this.serverService.getVideoPrivacies() this.serverService.getVideoPrivacies()
.subscribe(privacies => { .subscribe(privacies => {
this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies) this.videoPrivacies = this.videoService.explainedPrivacyLabels(privacies).videoPrivacies
if (this.schedulePublicationPossible) { if (this.schedulePublicationPossible) {
this.videoPrivacies.push({ this.videoPrivacies.push({
id: this.SPECIAL_SCHEDULED_PRIVACY, id: this.SPECIAL_SCHEDULED_PRIVACY,
......
...@@ -30,8 +30,6 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView ...@@ -30,8 +30,6 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView
videoUUID: string videoUUID: string
error: string error: string
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formValidatorService: FormValidatorService,
protected loadingBar: LoadingBarService, protected loadingBar: LoadingBarService,
......
...@@ -32,8 +32,6 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af ...@@ -32,8 +32,6 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
video: VideoEdit video: VideoEdit
error: string error: string
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formValidatorService: FormValidatorService,
protected loadingBar: LoadingBarService, protected loadingBar: LoadingBarService,
......
...@@ -31,8 +31,6 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV ...@@ -31,8 +31,6 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
video: VideoEdit video: VideoEdit
error: string error: string
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
constructor ( constructor (
protected formValidatorService: FormValidatorService, protected formValidatorService: FormValidatorService,
protected loadingBar: LoadingBarService, protected loadingBar: LoadingBarService,
......
...@@ -20,7 +20,6 @@ export abstract class VideoSend extends FormReactive implements OnInit { ...@@ -20,7 +20,6 @@ export abstract class VideoSend extends FormReactive implements OnInit {
abstract firstStepDone: EventEmitter<string> abstract firstStepDone: EventEmitter<string>
abstract firstStepError: EventEmitter<void> abstract firstStepError: EventEmitter<void>
protected abstract readonly DEFAULT_VIDEO_PRIVACY: VideoPrivacy
protected loadingBar: LoadingBarService protected loadingBar: LoadingBarService
protected notifier: Notifier protected notifier: Notifier
...@@ -46,9 +45,10 @@ export abstract class VideoSend extends FormReactive implements OnInit { ...@@ -46,9 +45,10 @@ export abstract class VideoSend extends FormReactive implements OnInit {
this.serverService.getVideoPrivacies() this.serverService.getVideoPrivacies()
.subscribe( .subscribe(
privacies => { 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
}) })
} }
......
...@@ -46,7 +46,6 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy ...@@ -46,7 +46,6 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
enableRetryAfterError: boolean enableRetryAfterError: boolean
// So that it can be accessed in the template // 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' protected readonly BASE_VIDEO_UPLOAD_URL = VideoService.BASE_VIDEO_URL + 'upload-resumable'
private uploadxOptions: UploadxOptions private uploadxOptions: UploadxOptions
......
import { Observable, of, throwError } from 'rxjs' import { Observable } from 'rxjs'
import { catchError, map, mergeMap, switchMap } from 'rxjs/operators' import { catchError, map, switchMap } from 'rxjs/operators'
import { HttpClient, HttpErrorResponse, HttpParams, HttpRequest } from '@angular/common/http' import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
import { Injectable } from '@angular/core' 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 { objectToFormData } from '@app/helpers'
import { import {
FeedFormat, FeedFormat,
...@@ -378,7 +378,7 @@ export class VideoService implements VideosProvider { ...@@ -378,7 +378,7 @@ export class VideoService implements VideosProvider {
) )
} }
explainedPrivacyLabels (privacies: VideoConstant<VideoPrivacy>[]) { explainedPrivacyLabels (privacies: VideoConstant<VideoPrivacy>[], defaultPrivacyId = VideoPrivacy.PUBLIC) {
const base = [ const base = [
{ {
id: VideoPrivacy.PRIVATE, id: VideoPrivacy.PRIVATE,
...@@ -398,9 +398,14 @@ export class VideoService implements VideosProvider { ...@@ -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 .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 .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) { nsfwPolicyToParam (nsfwPolicy: NSFWPolicyType) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment