mirror of
https://github.com/element-hq/element-desktop.git
synced 2025-12-23 23:59:16 -05:00
Merge pull request #2749 from element-hq/midhun/fix/681
Fix `Ctrl+Q` not closing the app
This commit is contained in:
@@ -504,11 +504,18 @@ app.on("ready", async () => {
|
||||
});
|
||||
|
||||
global.mainWindow.webContents.on("before-input-event", (event: Event, input: Input): void => {
|
||||
const shouldWarnBeforeExit = store.get("warnBeforeExit", true);
|
||||
const exitShortcutPressed =
|
||||
input.type === "keyDown" && exitShortcuts.some((shortcutFn) => shortcutFn(input, process.platform));
|
||||
|
||||
if (shouldWarnBeforeExit && exitShortcutPressed && global.mainWindow) {
|
||||
// We only care about the exit shortcuts here
|
||||
if (!exitShortcutPressed || !global.mainWindow) return;
|
||||
|
||||
// Prevent the default behaviour
|
||||
event.preventDefault();
|
||||
|
||||
// Let's ask the user if they really want to exit the app
|
||||
const shouldWarnBeforeExit = store.get("warnBeforeExit", true);
|
||||
if (shouldWarnBeforeExit) {
|
||||
const shouldCancelCloseRequest =
|
||||
dialog.showMessageBoxSync(global.mainWindow, {
|
||||
type: "question",
|
||||
@@ -522,11 +529,11 @@ app.on("ready", async () => {
|
||||
defaultId: 1,
|
||||
cancelId: 0,
|
||||
}) === 0;
|
||||
|
||||
if (shouldCancelCloseRequest) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (shouldCancelCloseRequest) return;
|
||||
}
|
||||
|
||||
// Exit the app
|
||||
app.exit();
|
||||
});
|
||||
|
||||
global.mainWindow.on("closed", () => {
|
||||
|
||||
Reference in New Issue
Block a user