From 0912f1b4caaa7394516567044f896132ad991131 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 6 Dec 2019 08:45:51 +0100 Subject: [PATCH] Fix build --- .../+signup/+register/register.component.ts | 1 + client/src/app/core/plugins/hooks.service.ts | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/client/src/app/+signup/+register/register.component.ts b/client/src/app/+signup/+register/register.component.ts index 5a7215516..acec56f04 100644 --- a/client/src/app/+signup/+register/register.component.ts +++ b/client/src/app/+signup/+register/register.component.ts @@ -103,6 +103,7 @@ export class RegisterComponent implements OnInit { const body: UserRegister = await this.hooks.wrapObject( Object.assign(this.formStepUser.value, { channel: this.formStepChannel.value }), + 'signup', 'filter:api.signup.registration.create.params' ) diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts index 242741831..a6a444c32 100644 --- a/client/src/app/core/plugins/hooks.service.ts +++ b/client/src/app/core/plugins/hooks.service.ts @@ -18,11 +18,10 @@ export class HooksService { wrapObsFun - (fun: ObservableFunction, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) - { + (fun: ObservableFunction, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) { return from(this.pluginService.ensurePluginsAreLoaded(scope)) .pipe( - mergeMap(() => this.wrapObject(params, hookParamName)), + mergeMap(() => this.wrapObjectWithoutScopeLoad(params, hookParamName)), switchMap(params => fun(params)), mergeMap(result => this.pluginService.runHook(hookResultName, result, params)) ) @@ -30,11 +29,10 @@ export class HooksService { async wrapFun - (fun: RawFunction, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) - { + (fun: RawFunction, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) { await this.pluginService.ensurePluginsAreLoaded(scope) - const newParams = await this.wrapObject(params, hookParamName) + const newParams = await this.wrapObjectWithoutScopeLoad(params, hookParamName) const result = fun(newParams) return this.pluginService.runHook(hookResultName, result, params) @@ -46,7 +44,13 @@ export class HooksService { .catch((err: any) => console.error('Fatal hook error.', { err })) } - private wrapObject (result: T, hookName: U) { + async wrapObject (result: T, scope: PluginClientScope, hookName: U) { + await this.pluginService.ensurePluginsAreLoaded(scope) + + return this.wrapObjectWithoutScopeLoad(result, hookName) + } + + private wrapObjectWithoutScopeLoad (result: T, hookName: U) { return this.pluginService.runHook(hookName, result) } } -- 2.25.1