From 786934b72c704a83901320ab08c290edb71529a3 Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Wed, 13 Nov 2019 16:31:29 -0500 Subject: [PATCH] Add onDesktopDisconnect hook, refactor plugin hooks on front end to be variable --- pluginHandler.js | 10 ++++++---- views/default.handlebars | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pluginHandler.js b/pluginHandler.js index 83f5d194..ced5d439 100644 --- a/pluginHandler.js +++ b/pluginHandler.js @@ -66,13 +66,15 @@ module.exports.pluginHandler = function (parent) { } } - str += `obj.onDeviceRefeshEnd = function(nodeid, panel, refresh, event) { - for (const p of Object.keys(obj)) { - if (typeof obj[p].onDeviceRefreshEnd == 'function') { - obj[p].onDeviceRefreshEnd(nodeid, panel, refresh, event); + str += ` + obj.callHook = function(hookName, ...args) { + for (const p of Object.keys(obj)) { + if (typeof obj[p][hookName] == 'function') { + obj[p][hookName](args); } } }; + obj.registerPluginTab = function(pluginRegInfo) { var d = pluginRegInfo(); if (!Q(d.tabId)) { diff --git a/views/default.handlebars b/views/default.handlebars index 322c8b79..4e089038 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -4540,7 +4540,7 @@ p13clearConsoleMsg(); // Device refresh plugin handler - if (pluginHandler != null) { pluginHandler.onDeviceRefeshEnd(nodeid, panel, refresh, event); } + if (pluginHandler != null) { pluginHandler.callHook('onDeviceRefreshEnd', nodeid, panel, refresh, event); } } setupDesktop(); // Always refresh the desktop, even if we are on the same device, we need to do some canvas switching. if (!panel) panel = 10; @@ -5201,6 +5201,7 @@ desktop.Stop(); webRtcDesktopReset(); desktopNode = desktop = null; + if (pluginHandler != null) { pluginHandler.callHook('onDesktopDisconnect'); } } }