diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js index c570068cf..75e37315f 100644 --- a/src/static/js/pluginfw/hooks.js +++ b/src/static/js/pluginfw/hooks.js @@ -362,7 +362,10 @@ exports.callFirst = (hookName, context) => { return []; }; -const aCallFirst = async (hookName, context, predicate = null) => { +exports.aCallFirst = async (hookName, context, cb = null, predicate = null) => { + if (cb != null) { + return await attachCallback(exports.aCallFirst(hookName, context, null, predicate), cb); + } if (!context) context = {}; if (predicate == null) predicate = (val) => val.length; const hooks = pluginDefs.hooks[hookName] || []; @@ -373,12 +376,6 @@ const aCallFirst = async (hookName, context, predicate = null) => { return []; }; -/* return a Promise if cb is not supplied */ -exports.aCallFirst = (hookName, context, cb, predicate) => { - if (cb == null) return aCallFirst(hookName, context, predicate); - util.callbackify(aCallFirst)(hookName, context, predicate, cb); -}; - exports.exportedForTestingOnly = { callHookFnAsync, callHookFnSync,