From b0f5d5a5941cb54375496155d5ffc5021a7540dd Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sun, 31 Jan 2021 16:58:27 -0500 Subject: [PATCH] fix: crash on firing action hook that had no listeners registered --- public/src/modules/hooks.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/src/modules/hooks.js b/public/src/modules/hooks.js index 38ac1f5dcf..1a5b7cdf32 100644 --- a/public/src/modules/hooks.js +++ b/public/src/modules/hooks.js @@ -36,6 +36,10 @@ define('hooks', [], () => { }; const _fireActionHook = (hookName, data) => { + if (!Hooks.hasListeners(hookName)) { + return; + } + Hooks.loaded[hookName].forEach(listener => listener(data)); // Backwards compatibility (remove this when we eventually remove jQuery from NodeBB core)