refactor: replace ipcRendererUtils.invoke() with ipcRendererInternal.invoke() (#19574)
This commit is contained in:
parent
698120daf0
commit
81e9dab52f
29 changed files with 195 additions and 164 deletions
|
@ -327,14 +327,15 @@ WebContents.prototype._init = function () {
|
|||
}
|
||||
})
|
||||
|
||||
this.on('-ipc-invoke', function (event, channel, args) {
|
||||
this.on('-ipc-invoke', function (event, internal, channel, args) {
|
||||
event._reply = (result) => event.sendReply({ result })
|
||||
event._throw = (error) => {
|
||||
console.error(`Error occurred in handler for '${channel}':`, error)
|
||||
event.sendReply({ error: error.toString() })
|
||||
}
|
||||
if (ipcMain._invokeHandlers.has(channel)) {
|
||||
ipcMain._invokeHandlers.get(channel)(event, ...args)
|
||||
const target = internal ? ipcMainInternal : ipcMain
|
||||
if (target._invokeHandlers.has(channel)) {
|
||||
target._invokeHandlers.get(channel)(event, ...args)
|
||||
} else {
|
||||
event._throw(`No handler registered for '${channel}'`)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue