aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts15
-rw-r--r--client/src/app/core/plugins/hooks.service.ts17
2 files changed, 8 insertions, 24 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
index ebfb42711..1834f7be5 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/metadata/video-attributes.component.ts
@@ -22,11 +22,11 @@ export class VideoAttributesComponent implements OnInit {
22 constructor (private hooks: HooksService) { } 22 constructor (private hooks: HooksService) { }
23 23
24 async ngOnInit () { 24 async ngOnInit () {
25 this.pluginMetadata = await this.hooks.wrapFunResult( 25 this.pluginMetadata = await this.hooks.wrapObject(
26 this.buildPluginMetadata.bind(this), 26 this.pluginMetadata,
27 { video: this.video },
28 'video-watch', 27 'video-watch',
29 'filter:video-watch.video-plugin-metadata.result' 28 'filter:video-watch.video-plugin-metadata.result',
29 { video: this.video }
30 ) 30 )
31 } 31 }
32 32
@@ -39,11 +39,4 @@ export class VideoAttributesComponent implements OnInit {
39 39
40 return this.video.tags 40 return this.video.tags
41 } 41 }
42
43 // Used for plugin hooks
44 private buildPluginMetadata (_options: {
45 video: VideoDetails
46 }): PluginMetadata[] {
47 return []
48 }
49} 42}
diff --git a/client/src/app/core/plugins/hooks.service.ts b/client/src/app/core/plugins/hooks.service.ts
index f325605e9..d9fef8389 100644
--- a/client/src/app/core/plugins/hooks.service.ts
+++ b/client/src/app/core/plugins/hooks.service.ts
@@ -48,15 +48,6 @@ export class HooksService {
48 return this.pluginService.runHook(hookResultName, result, params) 48 return this.pluginService.runHook(hookResultName, result, params)
49 } 49 }
50 50
51 async wrapFunResult <P, R, H extends ClientFilterHookName>
52 (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookResultName: H) {
53 await this.pluginService.ensurePluginsAreLoaded(scope)
54
55 const result = fun(params)
56
57 return this.pluginService.runHook(hookResultName, result, params)
58 }
59
60 runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) { 51 runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) {
61 // Use setTimeout to give priority to Angular change detector 52 // Use setTimeout to give priority to Angular change detector
62 setTimeout(() => { 53 setTimeout(() => {
@@ -66,13 +57,13 @@ export class HooksService {
66 }) 57 })
67 } 58 }
68 59
69 async wrapObject<T, U extends ClientFilterHookName> (result: T, scope: PluginClientScope, hookName: U) { 60 async wrapObject<T, U extends ClientFilterHookName> (result: T, scope: PluginClientScope, hookName: U, context?: any) {
70 await this.pluginService.ensurePluginsAreLoaded(scope) 61 await this.pluginService.ensurePluginsAreLoaded(scope)
71 62
72 return this.wrapObjectWithoutScopeLoad(result, hookName) 63 return this.wrapObjectWithoutScopeLoad(result, hookName, context)
73 } 64 }
74 65
75 private wrapObjectWithoutScopeLoad<T, U extends ClientFilterHookName> (result: T, hookName: U) { 66 private wrapObjectWithoutScopeLoad<T, U extends ClientFilterHookName> (result: T, hookName: U, context?: any) {
76 return this.pluginService.runHook(hookName, result) 67 return this.pluginService.runHook(hookName, result, context)
77 } 68 }
78} 69}