Consolidate code for sending messages between processes to a window

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne SavolainenandMikko Aspiala committed 2022-05-20 14:10:14 +03:00
1 parent eb1a2488b1
commit 3d2c940a7c
4 files changed
+5 -5

No files matched your search

@@ -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);
@@ -14,7 +14,7 @@ export interface SendToViewArgs {
export interface LensWindow {
show: () => Promise<void>;
close: () => void;
send: (args: SendToViewArgs) => Promise<void>;
send: (args: SendToViewArgs) => void;
visible: boolean;
}
@@ -36,7 +36,7 @@ const navigateForExtensionInjectable = getInjectable({
(frameInfo) => frameInfo.frameId === frameId,
);
await applicationWindow.send({
applicationWindow.send({
channel: "extension:navigate",
frameInfo,
data: [extId, pageId, params],
@@ -29,7 +29,7 @@ const navigateInjectable = getInjectable({
? IpcRendererNavigationEvents.NAVIGATE_IN_CLUSTER
: IpcRendererNavigationEvents.NAVIGATE_IN_APP;
await applicationWindow.send({
applicationWindow.send({
channel,
frameInfo,
data: [url],