diff --git a/src/main-process/atom-application.js b/src/main-process/atom-application.js index dfe7797c1..49c691b66 100644 --- a/src/main-process/atom-application.js +++ b/src/main-process/atom-application.js @@ -1300,17 +1300,16 @@ class AtomApplication extends EventEmitter { // File dialog defaults to project directory of currently active editor if (path) openOptions.defaultPath = path - return dialog.showOpenDialog(parentWindow, openOptions, callback) + dialog.showOpenDialog(parentWindow, openOptions, callback) } promptForRestart () { - const chosen = dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { + dialog.showMessageBox(BrowserWindow.getFocusedWindow(), { type: 'warning', title: 'Restart required', message: 'You will need to restart Atom for this change to take effect.', buttons: ['Restart Atom', 'Cancel'] - }) - if (chosen === 0) return this.restart() + }, response => { if (response === 0) this.restart() }) } restart () { diff --git a/src/main-process/atom-window.js b/src/main-process/atom-window.js index 51558ad6f..dd7994e89 100644 --- a/src/main-process/atom-window.js +++ b/src/main-process/atom-window.js @@ -176,14 +176,13 @@ class AtomWindow extends EventEmitter { this.browserWindow.on('unresponsive', () => { if (this.isSpec) return - const chosen = dialog.showMessageBox(this.browserWindow, { + dialog.showMessageBox(this.browserWindow, { type: 'warning', buttons: ['Force Close', 'Keep Waiting'], message: 'Editor is not responding', detail: 'The editor is not responding. Would you like to force close it or just keep waiting?' - }) - if (chosen === 0) this.browserWindow.destroy() + }, response => { if (response === 0) this.browserWindow.destroy() }) }) this.browserWindow.webContents.on('crashed', async () => { @@ -194,16 +193,17 @@ class AtomWindow extends EventEmitter { } await this.fileRecoveryService.didCrashWindow(this) - const chosen = dialog.showMessageBox(this.browserWindow, { + dialog.showMessageBox(this.browserWindow, { type: 'warning', buttons: ['Close Window', 'Reload', 'Keep It Open'], message: 'The editor has crashed', detail: 'Please report this issue to https://github.com/atom/atom' + }, response => { + switch (response) { + case 0: return this.browserWindow.destroy() + case 1: return this.browserWindow.reload() + } }) - switch (chosen) { - case 0: return this.browserWindow.destroy() - case 1: return this.browserWindow.reload() - } }) this.browserWindow.webContents.on('will-navigate', (event, url) => { diff --git a/src/main-process/auto-update-manager.coffee b/src/main-process/auto-update-manager.coffee index 0e4144c1a..bc81d425d 100644 --- a/src/main-process/auto-update-manager.coffee +++ b/src/main-process/auto-update-manager.coffee @@ -118,24 +118,26 @@ class AutoUpdateManager onUpdateNotAvailable: => autoUpdater.removeListener 'error', @onUpdateError {dialog} = require 'electron' - dialog.showMessageBox + dialog.showMessageBox { type: 'info' buttons: ['OK'] icon: @iconPath message: 'No update available.' title: 'No Update Available' detail: "Version #{@version} is the latest version." + }, -> # noop callback to get async behavior onUpdateError: (event, message) => autoUpdater.removeListener 'update-not-available', @onUpdateNotAvailable {dialog} = require 'electron' - dialog.showMessageBox + dialog.showMessageBox { type: 'warning' buttons: ['OK'] icon: @iconPath message: 'There was an error checking for updates.' title: 'Update Error' detail: message + }, -> # noop callback to get async behavior getWindows: -> global.atomApplication.getAllWindows() diff --git a/src/main-process/file-recovery-service.js b/src/main-process/file-recovery-service.js index 58ca84943..eef84089d 100644 --- a/src/main-process/file-recovery-service.js +++ b/src/main-process/file-recovery-service.js @@ -65,7 +65,7 @@ class FileRecoveryService { `Error ${error.code}. There was a crash while saving "${recoveryFile.originalPath}", so this file might be blank or corrupted.\n` + `Atom couldn't recover it automatically, but a recovery file has been saved at: "${recoveryFile.recoveryPath}".` console.log(detail) - dialog.showMessageBox(window, {type: 'info', buttons: ['OK'], message, detail}) + dialog.showMessageBox(window, {type: 'info', buttons: ['OK'], message, detail}, () => { /* noop callback to get async behavior */ }) }) .then(() => { for (let window of this.windowsByRecoveryFile.get(recoveryFile)) {