diff options
author | Chocobozzz <me@florianbigard.com> | 2020-10-26 16:44:23 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | b5b687550d8ef8beafdf706e45d6556fb5f4c876 (patch) | |
tree | 232412d463c78af1f7ab5797db5aecf1096d08da /client/src/app/+videos/+video-edit/video-update.component.ts | |
parent | ef680f68351ec10ab73a1131570a6d14ce14c195 (diff) | |
download | PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.gz PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.tar.zst PeerTube-b5b687550d8ef8beafdf706e45d6556fb5f4c876.zip |
Add ability to save live replay
Diffstat (limited to 'client/src/app/+videos/+video-edit/video-update.component.ts')
-rw-r--r-- | client/src/app/+videos/+video-edit/video-update.component.ts | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts index ec1305a33..7126ad05b 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts | |||
@@ -3,10 +3,11 @@ import { Component, HostListener, OnInit } from '@angular/core' | |||
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { Notifier } from '@app/core' | 4 | import { Notifier } from '@app/core' |
5 | import { FormReactive, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms' | 5 | import { FormReactive, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms' |
6 | import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main' | 6 | import { LiveVideoService, VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main' |
7 | import { LoadingBarService } from '@ngx-loading-bar/core' | 7 | import { LoadingBarService } from '@ngx-loading-bar/core' |
8 | import { LiveVideo, VideoPrivacy } from '@shared/models' | 8 | import { LiveVideo, LiveVideoUpdate, VideoPrivacy } from '@shared/models' |
9 | import { hydrateFormFromVideo } from './shared/video-edit-utils' | 9 | import { hydrateFormFromVideo } from './shared/video-edit-utils' |
10 | import { of } from 'rxjs' | ||
10 | 11 | ||
11 | @Component({ | 12 | @Component({ |
12 | selector: 'my-videos-update', | 13 | selector: 'my-videos-update', |
@@ -32,7 +33,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
32 | private notifier: Notifier, | 33 | private notifier: Notifier, |
33 | private videoService: VideoService, | 34 | private videoService: VideoService, |
34 | private loadingBar: LoadingBarService, | 35 | private loadingBar: LoadingBarService, |
35 | private videoCaptionService: VideoCaptionService | 36 | private videoCaptionService: VideoCaptionService, |
37 | private liveVideoService: LiveVideoService | ||
36 | ) { | 38 | ) { |
37 | super() | 39 | super() |
38 | } | 40 | } |
@@ -56,7 +58,15 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
56 | } | 58 | } |
57 | 59 | ||
58 | // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout | 60 | // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout |
59 | setTimeout(() => hydrateFormFromVideo(this.form, this.video, true)) | 61 | setTimeout(() => { |
62 | hydrateFormFromVideo(this.form, this.video, true) | ||
63 | |||
64 | if (this.liveVideo) { | ||
65 | this.form.patchValue({ | ||
66 | saveReplay: this.liveVideo.saveReplay | ||
67 | }) | ||
68 | } | ||
69 | }) | ||
60 | }, | 70 | }, |
61 | 71 | ||
62 | err => { | 72 | err => { |
@@ -102,6 +112,10 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
102 | 112 | ||
103 | this.video.patch(this.form.value) | 113 | this.video.patch(this.form.value) |
104 | 114 | ||
115 | const liveVideoUpdate: LiveVideoUpdate = { | ||
116 | saveReplay: this.form.value.saveReplay | ||
117 | } | ||
118 | |||
105 | this.loadingBar.useRef().start() | 119 | this.loadingBar.useRef().start() |
106 | this.isUpdatingVideo = true | 120 | this.isUpdatingVideo = true |
107 | 121 | ||
@@ -109,7 +123,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
109 | this.videoService.updateVideo(this.video) | 123 | this.videoService.updateVideo(this.video) |
110 | .pipe( | 124 | .pipe( |
111 | // Then update captions | 125 | // Then update captions |
112 | switchMap(() => this.videoCaptionService.updateCaptions(this.video.id, this.videoCaptions)) | 126 | switchMap(() => this.videoCaptionService.updateCaptions(this.video.id, this.videoCaptions)), |
127 | |||
128 | switchMap(() => { | ||
129 | if (!this.liveVideo) return of(undefined) | ||
130 | |||
131 | return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate) | ||
132 | }) | ||
113 | ) | 133 | ) |
114 | .subscribe( | 134 | .subscribe( |
115 | () => { | 135 | () => { |