From 3d2c940a7c6cfca73dcfd2bcbad240cfbbd86ddd Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Mon, 16 May 2022 14:07:10 +0300 Subject: [PATCH] Consolidate code for sending messages between processes to a window Co-authored-by: Mikko Aspiala Signed-off-by: Janne Savolainen --- .../application-window/create-lens-window.injectable.ts | 4 ++-- .../application-window/lens-window-injection-token.ts | 2 +- .../lens-window/navigate-for-extension.injectable.ts | 2 +- .../start-main-application/lens-window/navigate.injectable.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts b/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts index cea2dace06..88e8c60095 100644 --- a/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts +++ b/src/main/start-main-application/lens-window/application-window/create-lens-window.injectable.ts @@ -60,9 +60,9 @@ const createLensWindowInjectable = getInjectable({ browserWindow?.close(); browserWindow = undefined; }, - send: async (args: SendToViewArgs) => { + send: (args: SendToViewArgs) => { if (!browserWindow) { - browserWindow = await createElectronWindow(); + throw new Error(`Tried to send message to window "${configuration.id}" but the window was closed`); } return browserWindow.send(args); diff --git a/src/main/start-main-application/lens-window/application-window/lens-window-injection-token.ts b/src/main/start-main-application/lens-window/application-window/lens-window-injection-token.ts index f7273206c9..3e62b0894b 100644 --- a/src/main/start-main-application/lens-window/application-window/lens-window-injection-token.ts +++ b/src/main/start-main-application/lens-window/application-window/lens-window-injection-token.ts @@ -14,7 +14,7 @@ export interface SendToViewArgs { export interface LensWindow { show: () => Promise; close: () => void; - send: (args: SendToViewArgs) => Promise; + send: (args: SendToViewArgs) => void; visible: boolean; } diff --git a/src/main/start-main-application/lens-window/navigate-for-extension.injectable.ts b/src/main/start-main-application/lens-window/navigate-for-extension.injectable.ts index 703ef15f60..7bada3f3bd 100644 --- a/src/main/start-main-application/lens-window/navigate-for-extension.injectable.ts +++ b/src/main/start-main-application/lens-window/navigate-for-extension.injectable.ts @@ -36,7 +36,7 @@ const navigateForExtensionInjectable = getInjectable({ (frameInfo) => frameInfo.frameId === frameId, ); - await applicationWindow.send({ + applicationWindow.send({ channel: "extension:navigate", frameInfo, data: [extId, pageId, params], diff --git a/src/main/start-main-application/lens-window/navigate.injectable.ts b/src/main/start-main-application/lens-window/navigate.injectable.ts index c7cbb10d24..f9d80e4205 100644 --- a/src/main/start-main-application/lens-window/navigate.injectable.ts +++ b/src/main/start-main-application/lens-window/navigate.injectable.ts @@ -29,7 +29,7 @@ const navigateInjectable = getInjectable({ ? IpcRendererNavigationEvents.NAVIGATE_IN_CLUSTER : IpcRendererNavigationEvents.NAVIGATE_IN_APP; - await applicationWindow.send({ + applicationWindow.send({ channel, frameInfo, data: [url],