Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confirmation modal from special iframe mfes #2594

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions core/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -832,19 +832,20 @@

resetConfirmationModalData();

export const showModal = (settings, openFromClient = false) => {
export const showModal = (settings, openFromClient = false, targetIframe) => {
return new Promise((resolve, reject) => {
confirmationModal = {
displayed: true,
settings,
openFromClient,
promise: { resolve, reject },
targetIframe,
};
});
};

const handleModalResult = (result) => {
const { promise, openFromClient } = confirmationModal;
const { promise, openFromClient, targetIframe } = confirmationModal;

resetConfirmationModalData();

Expand All @@ -854,13 +855,12 @@
promise.reject();
}

if (openFromClient) {
const iframe = Iframe.getActiveIframe(contentNode);
if (openFromClient && targetIframe) {
const message = {
msg: 'luigi.ux.confirmationModal.hide',
data: { confirmed: result },
};
IframeHelpers.sendMessageToIframe(iframe, message);
IframeHelpers.sendMessageToIframe(targetIframe, message);
}
};

Expand Down Expand Up @@ -1433,7 +1433,7 @@
const settings = e.data.data.settings;
contentNode = node;
resetConfirmationModalData();
showModal(settings, true).catch(() => {
showModal(settings, true, iframe).catch(() => {
/* keep it to avoid runtime errors in browser console */
});
}
Expand Down