From e3ac43004b440f3c0e1cf0cf36598458f768d6b9 Mon Sep 17 00:00:00 2001 From: Johnson Lai Date: Fri, 17 May 2024 08:48:37 +0800 Subject: [PATCH] add delete confirmation box before delete --- electron/main/index.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index e9fed329..e5f43362 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -173,8 +173,19 @@ ipcMain.handle("show-context-menu-file-item", (event, file) => { new MenuItem({ label: "Delete", click: () => { - console.log(file.path); - event.sender.send("delete-file-listener", file.path); + return dialog + .showMessageBox({ + type: "question", + title: "Delete File", + message: `Are you sure you want to delete "${file.name}"?`, + buttons: ["Yes", "No"], + }) + .then((confirm) => { + if (confirm.response === 0) { + console.log(file.path); + event.sender.send("delete-file-listener", file.path); + } + }); }, }) );