]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+videos/+video-edit/video-update.component.ts
Bidi support
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-edit / video-update.component.ts
index e2331c148ea8a072cff803bdb973bfc4e472f0df..574669a23731b54616ed80a911deb77597568e95 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)
           })
         )
@@ -150,7 +156,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
             this.isUpdatingVideo = false
             this.loadingBar.useRef().complete()
             this.notifier.success($localize`Video updated.`)
-            this.router.navigate([ '/videos/watch', this.video.uuid ])
+            this.router.navigate([ '/w', this.video.uuid ])
           },
 
           err => {