1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

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 Savolainen 2022-05-16 14:07:10 +03:00
parent eb1a2488b1
commit 3d2c940a7c
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
4 changed files with 5 additions and 5 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -36,7 +36,7 @@ const navigateForExtensionInjectable = getInjectable({
(frameInfo) => frameInfo.frameId === frameId,
);
await applicationWindow.send({
applicationWindow.send({
channel: "extension:navigate",
frameInfo,
data: [extId, pageId, params],

View File

@ -29,7 +29,7 @@ const navigateInjectable = getInjectable({
? IpcRendererNavigationEvents.NAVIGATE_IN_CLUSTER
: IpcRendererNavigationEvents.NAVIGATE_IN_APP;
await applicationWindow.send({
applicationWindow.send({
channel,
frameInfo,
data: [url],