refactor: make ELECTRON_INSPECTOR_CONFIRM handler async (#17378)

This commit is contained in:
Milan Burda 2019-03-14 23:29:40 +01:00 committed by Samuel Attard
parent cb4ede453f
commit f15d0b1ed7

View file

@ -97,22 +97,16 @@ ipcMainUtils.handle('ELECTRON_INSPECTOR_SELECT_FILE', async function (event) {
return [path, data]
})
ipcMainUtils.handle('ELECTRON_INSPECTOR_CONFIRM', function (event, message, title) {
return new Promise((resolve, reject) => {
assertChromeDevTools(event.sender, 'window.confirm()')
ipcMainUtils.handle('ELECTRON_INSPECTOR_CONFIRM', async function (event, message = '', title = '') {
assertChromeDevTools(event.sender, 'window.confirm()')
if (message == null) message = ''
if (title == null) title = ''
const options = {
message: `${message}`,
title: `${title}`,
buttons: ['OK', 'Cancel'],
cancelId: 1
}
const window = event.sender.getOwnerBrowserWindow()
dialog.showMessageBox(window, options, (response) => {
resolve(response === 0)
})
})
const options = {
message: String(message),
title: String(title),
buttons: ['OK', 'Cancel'],
cancelId: 1
}
const window = event.sender.getOwnerBrowserWindow()
const { response } = await dialog.showMessageBox(window, options)
return response === 0
})