aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-22 15:51:02 +0200
committerChocobozzz <me@florianbigard.com>2021-10-22 15:51:02 +0200
commit0ba9696c012804670ccdd5256acdaa7ed9484339 (patch)
tree50a1f5e47221c6c200260ab6af164e676a466de1 /client/src/app/+videos
parent382258676c3ab83f9cebfc4e378ab955cd8fd9ff (diff)
downloadPeerTube-0ba9696c012804670ccdd5256acdaa7ed9484339.tar.gz
PeerTube-0ba9696c012804670ccdd5256acdaa7ed9484339.tar.zst
PeerTube-0ba9696c012804670ccdd5256acdaa7ed9484339.zip
Cleanup video update component
Diffstat (limited to 'client/src/app/+videos')
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.ts3
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.html2
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.ts53
3 files changed, 27 insertions, 31 deletions
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 bf7fdeeed..b4638c2df 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
@@ -63,6 +63,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
63 63
64 @ViewChild('videoCaptionAddModal', { static: true }) videoCaptionAddModal: VideoCaptionAddModalComponent 64 @ViewChild('videoCaptionAddModal', { static: true }) videoCaptionAddModal: VideoCaptionAddModalComponent
65 65
66 @Output() formBuilt = new EventEmitter<void>()
66 @Output() pluginFieldsAdded = new EventEmitter<void>() 67 @Output() pluginFieldsAdded = new EventEmitter<void>()
67 68
68 // So that it can be accessed in the template 69 // So that it can be accessed in the template
@@ -154,6 +155,8 @@ export class VideoEditComponent implements OnInit, OnDestroy {
154 this.trackChannelChange() 155 this.trackChannelChange()
155 this.trackPrivacyChange() 156 this.trackPrivacyChange()
156 this.trackLivePermanentFieldChange() 157 this.trackLivePermanentFieldChange()
158
159 this.formBuilt.emit()
157 } 160 }
158 161
159 ngOnInit () { 162 ngOnInit () {
diff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.html
index 33e3ddd14..ca322318c 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.html
+++ b/client/src/app/+videos/+video-edit/video-update.component.html
@@ -12,6 +12,8 @@
12 [videoCaptions]="videoCaptions" [waitTranscodingEnabled]="isWaitTranscodingEnabled()" 12 [videoCaptions]="videoCaptions" [waitTranscodingEnabled]="isWaitTranscodingEnabled()"
13 type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()" 13 type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()"
14 [liveVideo]="liveVideo" [videoToUpdate]="videoDetails" 14 [liveVideo]="liveVideo" [videoToUpdate]="videoDetails"
15
16 (formBuilt)="onFormBuilt()"
15 ></my-video-edit> 17 ></my-video-edit>
16 18
17 <div class="submit-container"> 19 <div class="submit-container">
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 9bef60133..e44aea10a 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.ts
+++ b/client/src/app/+videos/+video-edit/video-update.component.ts
@@ -1,5 +1,5 @@
1import { of } from 'rxjs' 1import { of } from 'rxjs'
2import { map, switchMap } from 'rxjs/operators' 2import { switchMap } from 'rxjs/operators'
3import { SelectChannelItem } from 'src/types/select-options-item.model' 3import { SelectChannelItem } from 'src/types/select-options-item.model'
4import { Component, HostListener, OnInit } from '@angular/core' 4import { Component, HostListener, OnInit } from '@angular/core'
5import { ActivatedRoute, Router } from '@angular/router' 5import { ActivatedRoute, Router } from '@angular/router'
@@ -45,37 +45,28 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
45 ngOnInit () { 45 ngOnInit () {
46 this.buildForm({}) 46 this.buildForm({})
47 47
48 this.route.data 48 const { videoData } = this.route.snapshot.data
49 .pipe(map(data => data.videoData)) 49 const { video, videoChannels, videoCaptions, liveVideo } = videoData
50 .subscribe({
51 next: ({ video, videoChannels, videoCaptions, liveVideo }) => {
52 this.video = new VideoEdit(video)
53 this.videoDetails = video
54
55 this.userVideoChannels = videoChannels
56 this.videoCaptions = videoCaptions
57 this.liveVideo = liveVideo
58
59 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
60
61 // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
62 setTimeout(() => {
63 hydrateFormFromVideo(this.form, this.video, true)
64
65 if (this.liveVideo) {
66 this.form.patchValue({
67 saveReplay: this.liveVideo.saveReplay,
68 permanentLive: this.liveVideo.permanentLive
69 })
70 }
71 })
72 },
73 50
74 error: err => { 51 this.video = new VideoEdit(video)
75 console.error(err) 52 this.videoDetails = video
76 this.notifier.error(err.message) 53
77 } 54 this.userVideoChannels = videoChannels
78 }) 55 this.videoCaptions = videoCaptions
56 this.liveVideo = liveVideo
57
58 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
59 }
60
61 onFormBuilt () {
62 hydrateFormFromVideo(this.form, this.video, true)
63
64 if (this.liveVideo) {
65 this.form.patchValue({
66 saveReplay: this.liveVideo.saveReplay,
67 permanentLive: this.liveVideo.permanentLive
68 })
69 }
79 } 70 }
80 71
81 @HostListener('window:beforeunload', [ '$event' ]) 72 @HostListener('window:beforeunload', [ '$event' ])