]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add action:video-edit.form.updated hook
authorChocobozzz <me@florianbigard.com>
Fri, 10 Mar 2023 09:34:25 +0000 (10:34 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 10 Mar 2023 09:34:25 +0000 (10:34 +0100)
client/src/app/+videos/+video-edit/shared/video-edit.component.ts
shared/models/plugins/client/client-hook.model.ts

index 13359a4d16c9eaa8bf28d87c7c5e642ba086e8a6..e3bd5fe71e743ec447488686fd242b82ef474a9c 100644 (file)
@@ -240,7 +240,15 @@ export class VideoEditComponent implements OnInit, OnDestroy {
       this.schedulerInterval = setInterval(() => this.minScheduledDate = new Date(), 1000 * 60) // Update every minute
     })
 
-    this.hooks.runAction('action:video-edit.init', 'video-edit', { type: this.type })
+    const updateForm = (values: any) => {
+      this.form.patchValue(values)
+      this.cd.detectChanges()
+    }
+    this.hooks.runAction('action:video-edit.init', 'video-edit', { type: this.type, updateForm })
+
+    this.form.valueChanges.subscribe(() => {
+      this.hooks.runAction('action:video-edit.form.updated', 'video-edit', { type: this.type, formValues: this.form.value })
+    })
   }
 
   ngOnDestroy () {
index 20e019304deb3a0a1d0211962c550ea81ba1c756..ec1d2b5e5d698f2dc68fd685bef7c77049576fd4 100644 (file)
@@ -129,8 +129,12 @@ export const clientActionHookObject = {
   'action:video-channel-playlists.playlists.loaded': true,
 
   // Fired when the video edit page (upload, URL/torrent import, update) is being initialized
+  // Contains a `type` and `updateForm` object attributes
   'action:video-edit.init': true,
 
+  // Fired when values of the video edit form changed
+  'action:video-edit.form.updated': true,
+
   // Fired when the login page is being initialized
   'action:login.init': true,