aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/root-helpers/plugins-manager.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-01-24 13:42:55 +0100
committerChocobozzz <me@florianbigard.com>2023-01-24 13:42:55 +0100
commit2e5dd0bef8797dad82e5a908c30bc126cb924033 (patch)
tree3d2e160ce160a0386ab70cf6961d32d2b31f3f76 /client/src/root-helpers/plugins-manager.ts
parentb1d8261c458f5c9a800539d0aebc749e53dfcdbe (diff)
downloadPeerTube-2e5dd0bef8797dad82e5a908c30bc126cb924033.tar.gz
PeerTube-2e5dd0bef8797dad82e5a908c30bc126cb924033.tar.zst
PeerTube-2e5dd0bef8797dad82e5a908c30bc126cb924033.zip
Handle hook with Promise as result
Diffstat (limited to 'client/src/root-helpers/plugins-manager.ts')
-rw-r--r--client/src/root-helpers/plugins-manager.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/client/src/root-helpers/plugins-manager.ts b/client/src/root-helpers/plugins-manager.ts
index 6c64e2b01..31510d4e6 100644
--- a/client/src/root-helpers/plugins-manager.ts
+++ b/client/src/root-helpers/plugins-manager.ts
@@ -105,11 +105,16 @@ class PluginsManager {
105 } 105 }
106 } 106 }
107 107
108 async runHook<T> (hookName: ClientHookName, result?: T, params?: any) { 108 async runHook<T> (hookName: ClientHookName, resultArg?: T | Promise<T>, params?: any) {
109 if (!this.hooks[hookName]) return result 109 if (!this.hooks[hookName]) {
110 // eslint-disable-next-line no-return-await
111 return await resultArg
112 }
110 113
111 const hookType = getHookType(hookName) 114 const hookType = getHookType(hookName)
112 115
116 let result = await resultArg
117
113 for (const hook of this.hooks[hookName]) { 118 for (const hook of this.hooks[hookName]) {
114 logger.info(`Running hook ${hookName} of plugin ${hook.plugin.name}`) 119 logger.info(`Running hook ${hookName} of plugin ${hook.plugin.name}`)
115 120