diff options
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 | 53 |
1 files changed, 22 insertions, 31 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 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 @@ | |||
1 | import { of } from 'rxjs' | 1 | import { of } from 'rxjs' |
2 | import { map, switchMap } from 'rxjs/operators' | 2 | import { switchMap } from 'rxjs/operators' |
3 | import { SelectChannelItem } from 'src/types/select-options-item.model' | 3 | import { SelectChannelItem } from 'src/types/select-options-item.model' |
4 | import { Component, HostListener, OnInit } from '@angular/core' | 4 | import { Component, HostListener, OnInit } from '@angular/core' |
5 | import { ActivatedRoute, Router } from '@angular/router' | 5 | import { 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' ]) |