diff options
Diffstat (limited to 'client/main.js')
-rwxr-xr-x | client/main.js | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/client/main.js b/client/main.js index b3fd5b0..41550aa 100755 --- a/client/main.js +++ b/client/main.js @@ -2,7 +2,7 @@ const buildNumber = "main"; // --- >FINAL< @BUILDNUMBER@ >FINAL< --- // -let version = "2.9.5"; +let version = "2.9.7"; const { desktopCapturer, protocol, app, BrowserWindow, webContents, globalShortcut, nativeTheme, ipcMain, session, dialog, Menu } = require('electron'); const os = require("os"); @@ -149,15 +149,29 @@ const createWindow = () => { require("@electron/remote/main").enable(mainWindow.webContents); - mainWindow.on('close', (event) => { - if (dialog.showMessageBoxSync(global.mainWindow ?? null, { + let shouldExit = false; + + mainWindow.on('close', async (event) => { + if (shouldExit || fs.existsSync(app.getPath("userData") + "/disable-confirmation")) return; + event.preventDefault(); + + let status = await dialog.showMessageBox(global.mainWindow ?? null, { type: "warning", message: "Quit Chatroom?", + checkboxLabel: "Don't ask me again", + checkboxChecked: false, detail: "Are you sure you want to quit Chatroom? Unsaved data will be lost.", noLink: true, buttons: ["Yes", "No"] - }) === 1) { - event.preventDefault(); + }); + + if (status.response === 0) { + if (status.checkboxChecked) { + fs.writeFileSync(app.getPath("userData") + "/disable-confirmation", ""); + } + + shouldExit = true; + mainWindow.close(); } }); @@ -434,13 +448,6 @@ ipcMain.handle('reload', (_) => { }); }); -ipcMain.handle('platforms', (_, req) => { - return new Promise(async (res) => { - if (!global.mainWindow) return; - res(await global.mainWindow.webContents.executeJavaScript("platformsRequest(JSON.parse(atob(\"" + Buffer.from(JSON.stringify(req)).toString("base64") + "\")));")); - }); -}); - ipcMain.on('menu', (_, params) => { console.log(params); |