From 295106516277581ba4967199fa5580264a90ae2c Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Sat, 5 Jun 2021 11:05:25 +0200 Subject: allow public video privacy to be deleted in the web client --- .../+videos/+video-edit/shared/video-edit.component.ts | 2 +- .../video-add-components/video-go-live.component.ts | 2 -- .../video-import-torrent.component.ts | 2 -- .../video-add-components/video-import-url.component.ts | 2 -- .../+video-edit/video-add-components/video-send.ts | 6 +++--- .../video-add-components/video-upload.component.ts | 1 - .../src/app/shared/shared-main/video/video.service.ts | 17 +++++++++++------ 7 files changed, 15 insertions(+), 17 deletions(-) (limited to 'client/src') diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index c3299cade..aebd53318 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts @@ -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, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index 15178a267..4c39b276a 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts @@ -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, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts index 2837b30c1..172dd5ba5 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts @@ -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, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts index 7a9fe369f..2994d05fa 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts @@ -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, diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts index a185892fe..0e7a26a47 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts @@ -20,7 +20,6 @@ export abstract class VideoSend extends FormReactive implements OnInit { abstract firstStepDone: EventEmitter abstract firstStepError: EventEmitter - 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 }) } diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index e20f08879..f383662a1 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts @@ -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 diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index 7b17bd2ab..1410edd18 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -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[]) { + explainedPrivacyLabels (privacies: VideoConstant[], 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) { -- cgit v1.2.3