refactor: use ipcRendererUtils.invokeSync / ipcMainUtils.handleSync (#16759)

This commit is contained in:
Milan Burda 2019-02-06 18:53:29 +01:00 committed by Shelley Vohr
parent b7d8234a86
commit 4211a9c69f
3 changed files with 14 additions and 36 deletions

View file

@ -10,21 +10,10 @@ if (process.platform === 'linux' && process.type === 'renderer') {
// Read/write to find pasteboard over IPC since only main process is notified
// of changes
if (process.platform === 'darwin' && process.type === 'renderer') {
const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal')
const errorUtils = require('@electron/internal/common/error-utils')
const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils')
const invoke = function (command, ...args) {
const [ error, result ] = ipcRenderer.sendSync(command, ...args)
if (error) {
throw errorUtils.deserialize(error)
} else {
return result
}
}
clipboard.readFindText = (...args) => invoke('ELECTRON_BROWSER_CLIPBOARD_READ_FIND_TEXT', ...args)
clipboard.writeFindText = (...args) => invoke('ELECTRON_BROWSER_CLIPBOARD_WRITE_FIND_TEXT', ...args)
clipboard.readFindText = (...args) => ipcRendererUtils.invokeSync('ELECTRON_BROWSER_CLIPBOARD_READ_FIND_TEXT', ...args)
clipboard.writeFindText = (...args) => ipcRendererUtils.invokeSync('ELECTRON_BROWSER_CLIPBOARD_WRITE_FIND_TEXT', ...args)
}
module.exports = clipboard