Skip to content

Commit

Permalink
Fix loading and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
oxixes committed Jan 12, 2024
1 parent f46fca1 commit 04e702f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
15 changes: 8 additions & 7 deletions src/wirecloud/platform/static/js/wirecloud/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,24 @@
// 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 {
this.widgetClass = Wirecloud.createAPIComponent("widget", this.meta.requirements, entrypoint,
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 {
Expand All @@ -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() {
Expand Down
16 changes: 8 additions & 8 deletions src/wirecloud/platform/static/js/wirecloud/wiring/Operator.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,22 @@
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 {
this.operatorClass = Wirecloud.createAPIComponent("operator", this.meta.requirements, entrypoint,
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."), {
Expand All @@ -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() {
Expand Down

0 comments on commit 04e702f

Please sign in to comment.