From 094f6cb5ec12914f0fe45275f4e2a81613af3679 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sun, 27 Jul 2025 21:45:27 +1200 Subject: [PATCH] added custom confirm dialog as js confirm in electron on windows causes all text fields to be disabled --- electron/main.js | 21 +++++++++++++++++++ electron/preload.js | 5 +++++ src/frontend/components/App.vue | 4 ++-- src/frontend/components/call/CallPage.vue | 7 ++++--- .../components/interfaces/InterfacesPage.vue | 2 +- .../messages/ConversationDropDownMenu.vue | 2 +- .../messages/ConversationViewer.vue | 14 ++++++------- .../nomadnetwork/NomadNetworkPage.vue | 6 +++--- .../components/profile/ProfileIconPage.vue | 4 ++-- src/frontend/js/DialogUtils.js | 10 +++++++++ 10 files changed, 56 insertions(+), 19 deletions(-) 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 @@