From fd0fdc46961ff9aa5c04e1c73b9b4e5e0cbbda8b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 26 Jan 2021 15:28:38 +0100 Subject: Don't update live attributes if they did not change --- .../app/+videos/+video-edit/video-update.component.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'client/src/app/+videos/+video-edit/video-update.component.ts') 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 e2331c148..f27ebd20e 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts @@ -124,11 +124,6 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.video.patch(this.form.value) - const liveVideoUpdate: LiveVideoUpdate = { - saveReplay: this.form.value.saveReplay, - permanentLive: this.form.value.permanentLive - } - this.loadingBar.useRef().start() this.isUpdatingVideo = true @@ -141,6 +136,19 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { switchMap(() => { if (!this.liveVideo) return of(undefined) + const liveVideoUpdate: LiveVideoUpdate = { + saveReplay: this.form.value.saveReplay, + permanentLive: this.form.value.permanentLive + } + + console.log(liveVideoUpdate) + console.log(this.form.value) + + // Don't update live attributes if they did not change + const liveChanged = Object.keys(liveVideoUpdate) + .some(key => this.liveVideo[key] !== liveVideoUpdate[key]) + if (!liveChanged) return of(undefined) + return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate) }) ) -- cgit v1.2.3