Skip to content

Commit

Permalink
fix(editor): Fix emitting n8nReady notification via postmessage o…
Browse files Browse the repository at this point in the history
…n new canvas (#11558)
  • Loading branch information
alexgrozav authored Nov 5, 2024
1 parent ef54760 commit 463d101
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/editor-ui/src/views/NodeView.v2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,13 @@ function removeSourceControlEventBindings() {
function addPostMessageEventBindings() {
window.addEventListener('message', onPostMessageReceived);
}
function removePostMessageEventBindings() {
window.removeEventListener('message', onPostMessageReceived);
}
function emitPostMessageReady() {
if (window.parent) {
window.parent.postMessage(
JSON.stringify({ command: 'n8nReady', version: rootStore.versionCli }),
Expand All @@ -1285,10 +1291,6 @@ function addPostMessageEventBindings() {
}
}
function removePostMessageEventBindings() {
window.removeEventListener('message', onPostMessageReceived);
}
async function onPostMessageReceived(messageEvent: MessageEvent) {
if (
!messageEvent ||
Expand Down Expand Up @@ -1516,6 +1518,8 @@ onBeforeMount(() => {
if (!isDemoRoute.value) {
pushConnectionStore.pushConnect();
}
addPostMessageEventBindings();
});
onMounted(() => {
Expand All @@ -1536,6 +1540,8 @@ onMounted(() => {
canvasStore.stopLoading();
void externalHooks.run('nodeView.mount').catch(() => {});
emitPostMessageReady();
});
void usersStore.showPersonalizationSurvey();
Expand All @@ -1544,7 +1550,6 @@ onMounted(() => {
});
addSourceControlEventBindings();
addPostMessageEventBindings();
addWorkflowSavedEventBindings();
addBeforeUnloadEventBindings();
addImportEventBindings();
Expand Down

0 comments on commit 463d101

Please sign in to comment.