]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/plugins/hooks.service.ts
Add ability for plugins to add metadata
[github/Chocobozzz/PeerTube.git] / client / src / app / core / plugins / hooks.service.ts
index 29db75d89bea8b7d24ddb073d517cdb4bee4fc6f..f325605e908870e5fbe503431eac5bc8208801e7 100644 (file)
@@ -48,6 +48,15 @@ export class HooksService {
     return this.pluginService.runHook(hookResultName, result, params)
   }
 
+  async wrapFunResult <P, R, H extends ClientFilterHookName>
+  (fun: RawFunction<P, R>, params: P, scope: PluginClientScope, hookResultName: H) {
+    await this.pluginService.ensurePluginsAreLoaded(scope)
+
+    const result = fun(params)
+
+    return this.pluginService.runHook(hookResultName, result, params)
+  }
+
   runAction<T, U extends ClientActionHookName> (hookName: U, scope: PluginClientScope, params?: T) {
     // Use setTimeout to give priority to Angular change detector
     setTimeout(() => {