aboutsummaryrefslogtreecommitdiff
path: root/src/app/main.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-04-29 00:30:29 +0200
committer0neGal <mail@0negal.com>2023-04-29 00:30:29 +0200
commit2a77d65c2276b9038bad4251692dc4a9c80029ce (patch)
tree3127ae172c8b91f466a55292d98f6f41c9122dc9 /src/app/main.js
parent35b0836701fb337b5e9ae9effb9ed9d788c8403c (diff)
downloadViper-2a77d65c2276b9038bad4251692dc4a9c80029ce.tar.gz
Viper-2a77d65c2276b9038bad4251692dc4a9c80029ce.zip
win.alert() now uses Promise, and added .confirm()
win.alert() now has a Promise return value, which'll allow you to wait until an alert has been closed before continuing code execution. win.confirm() was also added it's the same as win.alert() except it runs confirm() in the renderer instead of alert(), and has a return boolean in the Promise resolve callback. This boolean being whether the user confirmed the action or not.
Diffstat (limited to 'src/app/main.js')
-rw-r--r--src/app/main.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/app/main.js b/src/app/main.js
index 73537a2..72e0e09 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -232,7 +232,15 @@ ipcRenderer.on("newpath", (event, newpath) => {
// Continuation of log()
ipcRenderer.on("log", (event, msg) => {log(msg)})
-ipcRenderer.on("alert", (event, msg) => {alert(msg)})
+ipcRenderer.on("alert", (event, data) => {
+ alert(data.message);
+ ipcRenderer.send("alert-closed-" + data.id);
+})
+
+ipcRenderer.on("confirm", (event, data) => {
+ let confirmed = confirm(data.message);
+ ipcRenderer.send("confirm-closed-" + data.id, confirmed);
+})
// Updates the installed mods
ipcRenderer.on("mods", (event, mods_obj) => {