Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow public video privacy to be deleted in the web client #4163

Merged
merged 1 commit into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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