Fix build
authorChocobozzz <me@florianbigard.com>
Fri, 6 Dec 2019 07:45:51 +0000 (08:45 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 6 Dec 2019 07:45:51 +0000 (08:45 +0100)
client/src/app/+signup/+register/register.component.ts
client/src/app/core/plugins/hooks.service.ts

index 5a7215516a4127ac9e16961a2568b394a894e50e..acec56f04293439a3255f9f88ec63800689ba51a 100644 (file)
@@ -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'
     )
 
index 24274183129ec55c5b5f26ab09ec624edc6a6bb3..a6a444c326a4b3392f1cd651890c07894922b224 100644 (file)
@@ -18,11 +18,10 @@ export class HooksService {
 
   wrapObsFun
     <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName>
-    (fun: ObservableFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2)
-  {
+    (fun: ObservableFunction<P, R>, 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
     <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName>
-    (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2)
-  {
+    (fun: RawFunction<P, R>, 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<T, U extends ClientFilterHookName> (result: T, hookName: U) {
+  async wrapObject<T, U extends ClientFilterHookName> (result: T, scope: PluginClientScope, hookName: U) {
+    await this.pluginService.ensurePluginsAreLoaded(scope)
+
+    return this.wrapObjectWithoutScopeLoad(result, hookName)
+  }
+
+  private wrapObjectWithoutScopeLoad<T, U extends ClientFilterHookName> (result: T, hookName: U) {
     return this.pluginService.runHook(hookName, result)
   }
 }