Skip to content

Commit

Permalink
allow public video privacy to be deleted in the web client
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelk committed Jun 7, 2021
1 parent fc21ef5 commit f26978e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions client/src/app/shared/shared-main/video/video.service.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit f26978e

Please sign in to comment.