Skip to content

Commit a686ee4

Browse files
committed
fix: remove alert patch as tauri fixed alert issue in windows
1 parent d09dfd5 commit a686ee4

File tree

3 files changed

+5
-28
lines changed

3 files changed

+5
-28
lines changed

src/LiveDevelopment/BrowserScripts/LivePreviewTransportRemote.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -329,38 +329,16 @@
329329
}
330330
});
331331

332-
let alertStr = "Alert", confirmStr = "Confirm";
333-
334-
function alertPatch(message) {
335-
// in tauri windows, only the prompt API works. so we use it for alerts as well
336-
// we cant use html alerts here as the alert api will pause js which we cant do via js alone.
337-
prompt(alertStr, message);
338-
}
339-
340-
function confirmPatch(message) {
341-
// in tauri windows, only the prompt API works. so we use it for confirm as well
342-
// we cant use html alerts here as the alert api will pause js which we cant do via js alone.
343-
const response = prompt(confirmStr, message);
344-
// prompt will return null if cancel is pressed
345-
return !!response;
346-
}
347-
348332
// this is for managing who am i context in iframes embedded in phoenix to have special handling.
349333
window.addEventListener('message', function(event) {
350334
if (!TRANSPORT_CONFIG.TRUSTED_ORIGINS_EMBED[event.origin]) {
351335
return; // Ignore messages from unexpected origins
352336
}
353337
if(event.data.type === "WHO_AM_I_RESPONSE") {
354338
window.__PHOENIX_EMBED_INFO = {
355-
isTauri: event.data.isTauri
339+
isTauri: event.data.isTauri,
340+
platform: event.data.platform
356341
};
357-
alertStr = event.data.alertStr || alertStr;
358-
confirmStr = event.data.confirmStr || confirmStr;
359-
if(event.data.isTauri && event.data.platform === 'win') {
360-
// patch alert and confirm as in windows iframes in tauri, these are not present.
361-
window.alert = alertPatch;
362-
window.confirm = confirmPatch;
363-
}
364342
}
365343
});
366344
if(window.self !== window.parent){

src/extensionsIntegrated/Phoenix-live-preview/main.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ define(function (require, exports, module) {
130130
iframeDom.contentWindow.postMessage({
131131
type: "WHO_AM_I_RESPONSE",
132132
isTauri: Phoenix.isNativeApp,
133-
platform: Phoenix.platform,
134-
alertStr: Strings.ALERT,
135-
confirmStr: Strings.CONFIRM
133+
platform: Phoenix.platform
136134
}, "*"); // this is not sensitive info, and is only dispatched if requested by the iframe
137135
}
138136
});

src/extensionsIntegrated/Phoenix-live-preview/markdown.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
if(event.data.type === "WHO_AM_I_RESPONSE") {
2929
window.__PHOENIX_EMBED_INFO = {
30-
isTauri: event.data.isTauri
30+
isTauri: event.data.isTauri,
31+
platform: event.data.platform
3132
};
3233
} else if(event.data.type === "_TEST_FOCUS_CLICK") { // for integ tests
3334
document.body.click();

0 commit comments

Comments
 (0)