mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-31 05:29:58 +01:00
Add prompt to warn before quitting the application
This commit is contained in:
parent
b309562244
commit
c9c0ceb757
@ -27,7 +27,7 @@ const argv = require('minimist')(process.argv, {
|
||||
alias: {help: "h"},
|
||||
});
|
||||
|
||||
const {app, ipcMain, powerSaveBlocker, BrowserWindow, Menu, autoUpdater, protocol} = require('electron');
|
||||
const {app, ipcMain, powerSaveBlocker, BrowserWindow, Menu, autoUpdater, protocol, dialog} = require('electron');
|
||||
const AutoLaunch = require('auto-launch');
|
||||
const path = require('path');
|
||||
|
||||
@ -920,7 +920,22 @@ app.on('ready', async () => {
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = global.mainWindow = null;
|
||||
});
|
||||
mainWindow.on('close', (e) => {
|
||||
mainWindow.on('close', async (e) => {
|
||||
const shouldCancelCloseRequest = dialog.showMessageBoxSync(mainWindow, {
|
||||
type: "question",
|
||||
buttons: ["Cancel", "Close Element"],
|
||||
message: "Are you sure you want to quit?",
|
||||
defaultId: 1,
|
||||
cancelId: 0,
|
||||
checkboxLabel: "Do not show this again",
|
||||
checkboxChecked: false,
|
||||
}) === 0;
|
||||
|
||||
if (shouldCancelCloseRequest) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we are not quitting and have a tray icon then minimize to tray
|
||||
if (!global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) {
|
||||
// On Mac, closing the window just hides it
|
||||
|
Loading…
x
Reference in New Issue
Block a user