]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-edit/video-update.component.ts
fix likes bar, grid adjustment and menu width
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-edit / video-update.component.ts
index 952fe02933516d43fafaddd09d77b85e9daa5e40..0c60e3439c29433ef445e5162358b49deb6334e5 100644 (file)
@@ -29,6 +29,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
   schedulePublicationPossible = false
   videoCaptions: VideoCaptionEdit[] = []
 
+  private updateDone = false
+
   constructor (
     protected formValidatorService: FormValidatorService,
     private route: ActivatedRoute,
@@ -65,7 +67,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
             this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
           }
 
-          // FIXME: Angular does not detec
+          // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
           setTimeout(() => this.hydrateFormFromVideo())
         },
 
@@ -76,6 +78,16 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
       )
   }
 
+  canDeactivate () {
+    if (this.updateDone === true) return { canDeactivate: true }
+
+    for (const caption of this.videoCaptions) {
+      if (caption.action) return { canDeactivate: false }
+    }
+
+    return { canDeactivate: this.formChanged === false }
+  }
+
   checkForm () {
     this.forceCheck()
 
@@ -100,6 +112,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
         )
         .subscribe(
           () => {
+            this.updateDone = true
             this.isUpdatingVideo = false
             this.loadingBar.complete()
             this.notificationsService.success(this.i18n('Success'), this.i18n('Video updated.'))
@@ -113,7 +126,6 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
             console.error(err)
           }
         )
-
   }
 
   private hydrateFormFromVideo () {