diff options
Diffstat (limited to 'packages/main/src')
-rw-r--r-- | packages/main/src/index.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index 4a51518..b134002 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts | |||
@@ -219,8 +219,8 @@ function createWindow(): Promise<unknown> { | |||
219 | webContents.send(MainToRendererIpcMessage.SharedStorePatch, patch); | 219 | webContents.send(MainToRendererIpcMessage.SharedStorePatch, patch); |
220 | }); | 220 | }); |
221 | 221 | ||
222 | ipcMain.on(ServiceToMainIpcMessage.ApiExposedInMainWorld, (event) => { | 222 | ipcMain.handle(ServiceToMainIpcMessage.ApiExposedInMainWorld, (event) => { |
223 | event.returnValue = event.sender.id == browserView.webContents.id | 223 | return event.sender.id == browserView.webContents.id |
224 | ? serviceInject | 224 | ? serviceInject |
225 | : null; | 225 | : null; |
226 | }); | 226 | }); |
@@ -229,7 +229,8 @@ function createWindow(): Promise<unknown> { | |||
229 | try { | 229 | try { |
230 | switch (channel) { | 230 | switch (channel) { |
231 | case ServiceToMainIpcMessage.ApiExposedInMainWorld: | 231 | case ServiceToMainIpcMessage.ApiExposedInMainWorld: |
232 | // Synchronous message must be handled with `ipcMain.on` | 232 | // Asynchronous message with reply must be handled in `ipcMain.handle`, |
233 | // otherwise electron emits a no handler registered warning. | ||
233 | break; | 234 | break; |
234 | case ServiceToMainIpcMessage.SetUnreadCount: | 235 | case ServiceToMainIpcMessage.SetUnreadCount: |
235 | console.log('Unread count:', unreadCount.parse(args[0])); | 236 | console.log('Unread count:', unreadCount.parse(args[0])); |