X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-edit%2Fvideo-add-components%2Fvideo-go-live.component.ts;h=9868c37d2bb12616400d89505862d11d58cd5b9c;hb=b5b687550d8ef8beafdf706e45d6556fb5f4c876;hp=64fd4c4d4e145184c6e1317731ea045c04132dbc;hpb=c6c0fa6cd8fe8f752463d8982c3dbcd448739c4e;p=github%2FChocobozzz%2FPeerTube.git 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 64fd4c4d4..9868c37d2 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 @@ -1,12 +1,13 @@ +import { forkJoin } from 'rxjs' import { Component, EventEmitter, OnInit, Output } from '@angular/core' import { Router } from '@angular/router' import { AuthService, CanComponentDeactivate, Notifier, ServerService } from '@app/core' import { scrollToTop } from '@app/helpers' import { FormValidatorService } from '@app/shared/shared-forms' -import { VideoCaptionService, VideoEdit, VideoService, VideoLiveService } from '@app/shared/shared-main' +import { LiveVideoService, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' -import { VideoCreate, VideoLive, VideoPrivacy } from '@shared/models' +import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoPrivacy } from '@shared/models' import { VideoSend } from './video-send' @Component({ @@ -23,7 +24,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon isInUpdateForm = false - videoLive: VideoLive + liveVideo: LiveVideo videoId: number videoUUID: string error: string @@ -38,7 +39,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon protected serverService: ServerService, protected videoService: VideoService, protected videoCaptionService: VideoCaptionService, - private videoLiveService: VideoLiveService, + private liveVideoService: LiveVideoService, private router: Router ) { super() @@ -53,7 +54,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon } goLive () { - const video: VideoCreate = { + const video: LiveVideoCreate = { name: 'Live', privacy: VideoPrivacy.PRIVATE, nsfw: this.serverConfig.instance.isNSFW, @@ -69,7 +70,7 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId }) this.form.patchValue(toPatch) - this.videoLiveService.goLive(video).subscribe( + this.liveVideoService.goLive(video).subscribe( res => { this.videoId = res.video.id this.videoUUID = res.video.uuid @@ -95,29 +96,39 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, CanCompon video.id = this.videoId video.uuid = this.videoUUID + const liveVideoUpdate: LiveVideoUpdate = { + saveReplay: this.form.value.saveReplay + } + // Update the video - this.updateVideoAndCaptions(video) - .subscribe( - () => { - this.notifier.success($localize`Live published.`) + forkJoin([ + this.updateVideoAndCaptions(video), - this.router.navigate([ '/videos/watch', video.uuid ]) - }, + this.liveVideoService.updateLive(this.videoId, liveVideoUpdate) + ]).subscribe( + () => { + this.notifier.success($localize`Live published.`) + + this.router.navigate(['/videos/watch', video.uuid]) + }, - err => { - this.error = err.message - scrollToTop() - console.error(err) - } - ) + err => { + this.error = err.message + scrollToTop() + console.error(err) + } + ) + } + getMaxLiveDuration () { + return this.serverConfig.live.maxDuration / 1000 } private fetchVideoLive () { - this.videoLiveService.getVideoLive(this.videoId) + this.liveVideoService.getVideoLive(this.videoId) .subscribe( - videoLive => { - this.videoLive = videoLive + liveVideo => { + this.liveVideo = liveVideo }, err => {