]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+videos/+video-edit/video-update.component.ts
Add ability to set a custom quota
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-edit / video-update.component.ts
index e2331c148ea8a072cff803bdb973bfc4e472f0df..2973c6840619b6c0618b76ab710c3df9f25c627e 100644 (file)
@@ -1,9 +1,10 @@
 import { of } from 'rxjs'
 import { map, switchMap } from 'rxjs/operators'
+import { SelectChannelItem } from 'src/types/select-options-item.model'
 import { Component, HostListener, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { Notifier } from '@app/core'
-import { FormReactive, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 import { VideoCaptionEdit, VideoCaptionService, VideoDetails, VideoEdit, VideoService } from '@app/shared/shared-main'
 import { LiveVideoService } from '@app/shared/shared-video-live'
 import { LoadingBarService } from '@ngx-loading-bar/core'
@@ -124,11 +125,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 +137,16 @@ 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
+            }
+
+            // 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)
           })
         )