aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-06 08:45:51 +0100
committerChocobozzz <me@florianbigard.com>2019-12-06 08:45:51 +0100
commit0912f1b4caaa7394516567044f896132ad991131 (patch)
tree5bda1e29bdee63b89d0f4b18ddeb9cf9a230e52e /client/src/app/core
parentc2023a9f027deb310248ad751cc96a21a8e1ed03 (diff)
downloadPeerTube-0912f1b4caaa7394516567044f896132ad991131.tar.gz
PeerTube-0912f1b4caaa7394516567044f896132ad991131.tar.zst
PeerTube-0912f1b4caaa7394516567044f896132ad991131.zip
Fix build
Diffstat (limited to 'client/src/app/core')
-rw-r--r--client/src/app/core/plugins/hooks.service.ts18
1 files changed, 11 insertions, 7 deletions
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}