From 04e702f0ff14e49ff1868cb3c46a2c75d7938394 Mon Sep 17 00:00:00 2001 From: oxixes Date: Fri, 12 Jan 2024 19:39:14 +0100 Subject: [PATCH] Fix loading and improvements --- .../platform/static/js/wirecloud/Widget.js | 15 ++++++++------- .../static/js/wirecloud/wiring/Operator.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/wirecloud/platform/static/js/wirecloud/Widget.js b/src/wirecloud/platform/static/js/wirecloud/Widget.js index a36c795e8..6dfb5510c 100644 --- a/src/wirecloud/platform/static/js/wirecloud/Widget.js +++ b/src/wirecloud/platform/static/js/wirecloud/Widget.js @@ -312,7 +312,7 @@ // If this is a v2 or later widget, we need to instantiate it's entrypoint class _unloadScripts.call(this); _loadScripts.call(this).then(() => { - const entrypoint = eval("window[\"" + this.meta.entrypoint + "\"]"); + const entrypoint = window[this.meta.entrypoint]; if (entrypoint === undefined) { this.logManager.log("Widget entrypoint class not found!", {console: false}); } else { @@ -320,10 +320,16 @@ this.wrapperElement.shadowRoot, this.id, ('workspaceview' in this.tab.workspace.view) ? this.tab.workspace.view.workspaceview : undefined); } + + privates.get(this).status = STATUS.RUNNING; + + this.pending_events.forEach(send_pending_event, this); + this.pending_events = []; + + this.dispatchEvent('load'); }); } - privates.get(this).status = STATUS.RUNNING; if (this.meta.macversion > 1) { this.wrapperElement.addEventListener('unload', on_unload.bind(this), true); } else { @@ -340,11 +346,6 @@ level: Wirecloud.constants.LOGGING.INFO_MSG }); } - - this.dispatchEvent('load'); - - this.pending_events.forEach(send_pending_event, this); - this.pending_events = []; }; const on_unload = function on_unload() { diff --git a/src/wirecloud/platform/static/js/wirecloud/wiring/Operator.js b/src/wirecloud/platform/static/js/wirecloud/wiring/Operator.js index 7df1e3c20..6b3c21755 100644 --- a/src/wirecloud/platform/static/js/wirecloud/wiring/Operator.js +++ b/src/wirecloud/platform/static/js/wirecloud/wiring/Operator.js @@ -203,7 +203,7 @@ this.wrapperElement.contentDocument.defaultView.addEventListener('unload', on_unload.bind(this), true); } else if (!this.meta.missing && this.meta.macversion > 1) { // If this is a v2 or later operator, we need to instantiate it's entrypoint class - const entrypoint = eval("window[\"" + this.meta.entrypoint + "\"]"); + const entrypoint = window[this.meta.entrypoint]; if (entrypoint === undefined) { this.logManager.log("Operator entrypoint class not found!", {console: false}); } else { @@ -211,9 +211,14 @@ undefined, this.id, ('workspaceview' in this.wiring.workspace) ? this.wiring.workspace.workspaceview : undefined); } - } - privates.get(this).status = STATUS.RUNNING; + privates.get(this).status = STATUS.RUNNING; + + this.pending_events.forEach(send_pending_event, this); + this.pending_events = []; + + this.dispatchEvent('load'); + } if (this.missing) { this.logManager.log(utils.gettext("Failed to load operator."), { @@ -225,11 +230,6 @@ level: Wirecloud.constants.LOGGING.INFO_MSG }); } - - this.dispatchEvent('load'); - - this.pending_events.forEach(send_pending_event, this); - this.pending_events = []; }; const on_unload = function on_unload() {