aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/core/plugins/hooks.service.ts23
-rw-r--r--client/src/app/shared/images/global-icon.component.ts20
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts2
3 files changed, 34 insertions, 11 deletions
diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts
index 93dac1167..242741831 100644
--- a/client/src/app/core/plugins/hooks.service.ts
+++ b/client/src/app/core/plugins/hooks.service.ts
@@ -16,13 +16,10 @@ export class HooksService {
16 private pluginService: PluginService 16 private pluginService: PluginService
17 ) { } 17 ) { }
18 18
19 wrapObject<T, U extends ClientFilterHookName> (result: T, hookName: U) {
20 return this.pluginService.runHook(hookName, result)
21 }
22
23 wrapObsFun 19 wrapObsFun
24 <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName> 20 <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName>
25 (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 {
26 return from(this.pluginService.ensurePluginsAreLoaded(scope)) 23 return from(this.pluginService.ensurePluginsAreLoaded(scope))
27 .pipe( 24 .pipe(
28 mergeMap(() => this.wrapObject(params, hookParamName)), 25 mergeMap(() => this.wrapObject(params, hookParamName)),
@@ -31,10 +28,16 @@ export class HooksService {
31 ) 28 )
32 } 29 }
33 30
34 async wrapFun<U, T, V extends ClientFilterHookName> (fun: RawFunction<U, T>, params: U, hookName: V) { 31 async wrapFun
35 const result = fun(params) 32 <P, R, H1 extends ClientFilterHookName, H2 extends ClientFilterHookName>
33 (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookParamName: H1, hookResultName: H2)
34 {
35 await this.pluginService.ensurePluginsAreLoaded(scope)
36
37 const newParams = await this.wrapObject(params, hookParamName)
38 const result = fun(newParams)
36 39
37 return this.pluginService.runHook(hookName, result, params) 40 return this.pluginService.runHook(hookResultName, result, params)
38 } 41 }
39 42
40 runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) { 43 runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) {
@@ -42,4 +45,8 @@ export class HooksService {
42 .then(() => this.pluginService.runHook(hookName, undefined, params)) 45 .then(() => this.pluginService.runHook(hookName, undefined, params))
43 .catch((err: any) => console.error('Fatal hook error.', { err })) 46 .catch((err: any) => console.error('Fatal hook error.', { err }))
44 } 47 }
48
49 private wrapObject<T, U extends ClientFilterHookName> (result: T, hookName: U) {
50 return this.pluginService.runHook(hookName, result)
51 }
45} 52}
diff --git a/client/src/app/shared/images/global-icon.component.ts b/client/src/app/shared/images/global-icon.component.ts
index a13b7d8e0..eb723db94 100644
--- a/client/src/app/shared/images/global-icon.component.ts
+++ b/client/src/app/shared/images/global-icon.component.ts
@@ -1,4 +1,5 @@
1import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core' 1import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core'
2import { HooksService } from '@app/core/plugins/hooks.service'
2 3
3const icons = { 4const icons = {
4 'add': require('!!raw-loader?!../../../assets/images/global/add.svg'), 5 'add': require('!!raw-loader?!../../../assets/images/global/add.svg'),
@@ -60,11 +61,24 @@ export type GlobalIconName = keyof typeof icons
60export class GlobalIconComponent implements OnInit { 61export class GlobalIconComponent implements OnInit {
61 @Input() iconName: GlobalIconName 62 @Input() iconName: GlobalIconName
62 63
63 constructor (private el: ElementRef) {} 64 constructor (
65 private el: ElementRef,
66 private hooks: HooksService
67 ) { }
64 68
65 ngOnInit () { 69 async ngOnInit () {
66 const nativeElement = this.el.nativeElement 70 const nativeElement = this.el.nativeElement
67 71
68 nativeElement.innerHTML = icons[this.iconName] 72 nativeElement.innerHTML = await this.hooks.wrapFun(
73 this.getSVGContent.bind(this),
74 { name: this.iconName },
75 'common',
76 'filter:internal.common.svg-icons.get-content.params',
77 'filter:internal.common.svg-icons.get-content.result'
78 )
79 }
80
81 private getSVGContent (options: { name: string }) {
82 return icons[options.name]
69 } 83 }
70} 84}
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index 523865fef..adf6dc12f 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -418,6 +418,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
418 const { playerMode, playerOptions } = await this.hooks.wrapFun( 418 const { playerMode, playerOptions } = await this.hooks.wrapFun(
419 this.buildPlayerManagerOptions.bind(this), 419 this.buildPlayerManagerOptions.bind(this),
420 params, 420 params,
421 'video-watch',
422 'filter:internal.video-watch.player.build-options.params',
421 'filter:internal.video-watch.player.build-options.result' 423 'filter:internal.video-watch.player.build-options.result'
422 ) 424 )
423 425