From 085aba61c35ad63155a46453dff7752840e82146 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Mar 2023 10:34:25 +0100 Subject: Add action:video-edit.form.updated hook --- .../src/app/+videos/+video-edit/shared/video-edit.component.ts | 10 +++++++++- shared/models/plugins/client/client-hook.model.ts | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index 13359a4d1..e3bd5fe71 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts @@ -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 () { diff --git a/shared/models/plugins/client/client-hook.model.ts b/shared/models/plugins/client/client-hook.model.ts index 20e019304..ec1d2b5e5 100644 --- a/shared/models/plugins/client/client-hook.model.ts +++ b/shared/models/plugins/client/client-hook.model.ts @@ -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, -- cgit v1.2.3