refactor: make ELECTRON_INSPECTOR_CONFIRM handler async (#17378)
This commit is contained in:
parent
cb4ede453f
commit
f15d0b1ed7
1 changed files with 11 additions and 17 deletions
|
@ -97,22 +97,16 @@ ipcMainUtils.handle('ELECTRON_INSPECTOR_SELECT_FILE', async function (event) {
|
||||||
return [path, data]
|
return [path, data]
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMainUtils.handle('ELECTRON_INSPECTOR_CONFIRM', function (event, message, title) {
|
ipcMainUtils.handle('ELECTRON_INSPECTOR_CONFIRM', async function (event, message = '', title = '') {
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
assertChromeDevTools(event.sender, 'window.confirm()')
|
assertChromeDevTools(event.sender, 'window.confirm()')
|
||||||
|
|
||||||
if (message == null) message = ''
|
|
||||||
if (title == null) title = ''
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
message: `${message}`,
|
message: String(message),
|
||||||
title: `${title}`,
|
title: String(title),
|
||||||
buttons: ['OK', 'Cancel'],
|
buttons: ['OK', 'Cancel'],
|
||||||
cancelId: 1
|
cancelId: 1
|
||||||
}
|
}
|
||||||
const window = event.sender.getOwnerBrowserWindow()
|
const window = event.sender.getOwnerBrowserWindow()
|
||||||
dialog.showMessageBox(window, options, (response) => {
|
const { response } = await dialog.showMessageBox(window, options)
|
||||||
resolve(response === 0)
|
return response === 0
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue