diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-06 08:45:51 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-06 08:45:51 +0100 |
commit | 0912f1b4caaa7394516567044f896132ad991131 (patch) | |
tree | 5bda1e29bdee63b89d0f4b18ddeb9cf9a230e52e /client | |
parent | c2023a9f027deb310248ad751cc96a21a8e1ed03 (diff) | |
download | PeerTube-0912f1b4caaa7394516567044f896132ad991131.tar.gz PeerTube-0912f1b4caaa7394516567044f896132ad991131.tar.zst PeerTube-0912f1b4caaa7394516567044f896132ad991131.zip |
Fix build
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/+signup/+register/register.component.ts | 1 | ||||
-rw-r--r-- | 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 { | |||
103 | 103 | ||
104 | const body: UserRegister = await this.hooks.wrapObject( | 104 | const body: UserRegister = await this.hooks.wrapObject( |
105 | Object.assign(this.formStepUser.value, { channel: this.formStepChannel.value }), | 105 | Object.assign(this.formStepUser.value, { channel: this.formStepChannel.value }), |
106 | 'signup', | ||
106 | 'filter:api.signup.registration.create.params' | 107 | 'filter:api.signup.registration.create.params' |
107 | ) | 108 | ) |
108 | 109 | ||
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 { | |||
18 | 18 | ||
19 | wrapObsFun | 19 | wrapObsFun |
20 | <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> | 20 | <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> |
21 | (fun: ObservableFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) | 21 | (fun: ObservableFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) { |
22 | { | ||
23 | return from(this.pluginService.ensurePluginsAreLoaded(scope)) | 22 | return from(this.pluginService.ensurePluginsAreLoaded(scope)) |
24 | .pipe( | 23 | .pipe( |
25 | mergeMap(() => this.wrapObject(params, hookParamName)), | 24 | mergeMap(() => this.wrapObjectWithoutScopeLoad(params, hookParamName)), |
26 | switchMap(params => fun(params)), | 25 | switchMap(params => fun(params)), |
27 | mergeMap(result => this.pluginService.runHook(hookResultName, result, params)) | 26 | mergeMap(result => this.pluginService.runHook(hookResultName, result, params)) |
28 | ) | 27 | ) |
@@ -30,11 +29,10 @@ export class HooksService { | |||
30 | 29 | ||
31 | async wrapFun | 30 | async wrapFun |
32 | <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> | 31 | <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> |
33 | (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) | 32 | (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2) { |
34 | { | ||
35 | await this.pluginService.ensurePluginsAreLoaded(scope) | 33 | await this.pluginService.ensurePluginsAreLoaded(scope) |
36 | 34 | ||
37 | const newParams = await this.wrapObject(params, hookParamName) | 35 | const newParams = await this.wrapObjectWithoutScopeLoad(params, hookParamName) |
38 | const result = fun(newParams) | 36 | const result = fun(newParams) |
39 | 37 | ||
40 | return this.pluginService.runHook(hookResultName, result, params) | 38 | return this.pluginService.runHook(hookResultName, result, params) |
@@ -46,7 +44,13 @@ export class HooksService { | |||
46 | .catch((err: any) => console.error('Fatal hook error.', { err })) | 44 | .catch((err: any) => console.error('Fatal hook error.', { err })) |
47 | } | 45 | } |
48 | 46 | ||
49 | private wrapObject<T, U extends ClientFilterHookName> (result: T, hookName: U) { | 47 | async wrapObject<T, U extends ClientFilterHookName> (result: T, scope: PluginClientScope, hookName: U) { |
48 | await this.pluginService.ensurePluginsAreLoaded(scope) | ||
49 | |||
50 | return this.wrapObjectWithoutScopeLoad(result, hookName) | ||
51 | } | ||
52 | |||
53 | private wrapObjectWithoutScopeLoad<T, U extends ClientFilterHookName> (result: T, hookName: U) { | ||
50 | return this.pluginService.runHook(hookName, result) | 54 | return this.pluginService.runHook(hookName, result) |
51 | } | 55 | } |
52 | } | 56 | } |