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]
|
||||
})
|
||||
|
||||
ipcMainUtils.handle('ELECTRON_INSPECTOR_CONFIRM', function (event, message, title) {
|
||||
return new Promise((resolve, reject) => {
|
||||
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}`,
|
||||
message: String(message),
|
||||
title: String(title),
|
||||
buttons: ['OK', 'Cancel'],
|
||||
cancelId: 1
|
||||
}
|
||||
const window = event.sender.getOwnerBrowserWindow()
|
||||
dialog.showMessageBox(window, options, (response) => {
|
||||
resolve(response === 0)
|
||||
})
|
||||
})
|
||||
const { response } = await dialog.showMessageBox(window, options)
|
||||
return response === 0
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue