diff --git a/electron/main.js b/electron/main.js index 1c70182..bdaa0cc 100644 --- a/electron/main.js +++ b/electron/main.js @@ -22,6 +22,27 @@ ipcMain.handle('alert', async(event, message) => { }); }); +// add support for showing a confirm window via ipc +ipcMain.handle('confirm', async(event, message) => { + + // show confirm dialog + const result = await dialog.showMessageBox(mainWindow, { + type: "question", + title: "Confirm", + message: message, + cancelId: 0, // esc key should press cancel button + defaultId: 1, // enter key should press ok button + buttons: [ + "Cancel", // 0 + "OK", // 1 + ], + }); + + // check if user clicked OK + return result.response === 1; + +}); + // add support for showing a prompt window via ipc ipcMain.handle('prompt', async(event, message) => { return await electronPrompt({ diff --git a/electron/preload.js b/electron/preload.js index 8abc460..5465420 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -15,6 +15,11 @@ contextBridge.exposeInMainWorld('electron', { return await ipcRenderer.invoke('alert', message); }, + // show a confirm dialog in electron browser window, this fixes a bug where confirm breaks input fields on windows + confirm: async function(message) { + return await ipcRenderer.invoke('confirm', message); + }, + // add support for using "prompt" in electron browser window prompt: async function(message) { return await ipcRenderer.invoke('prompt', message); diff --git a/src/frontend/components/App.vue b/src/frontend/components/App.vue index ff92964..3e69308 100644 --- a/src/frontend/components/App.vue +++ b/src/frontend/components/App.vue @@ -448,7 +448,7 @@ export default { // ask to stop syncing if already syncing if(this.isSyncingPropagationNode){ - if(confirm("Are you sure you want to stop syncing?")){ + if(await DialogUtils.confirm("Are you sure you want to stop syncing?")){ await this.stopSyncingPropagationNode(); } return; @@ -529,7 +529,7 @@ export default { async hangupAllCalls() { // confirm user wants to hang up calls - if(!confirm("Are you sure you want to hang up all incoming and outgoing calls?")){ + if(!await DialogUtils.confirm("Are you sure you want to hang up all incoming and outgoing calls?")){ return; } diff --git a/src/frontend/components/call/CallPage.vue b/src/frontend/components/call/CallPage.vue index 509c3bc..cc74d2c 100644 --- a/src/frontend/components/call/CallPage.vue +++ b/src/frontend/components/call/CallPage.vue @@ -259,6 +259,7 @@