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:
parent
eb1a2488b1
commit
3d2c940a7c
@ -60,9 +60,9 @@ const createLensWindowInjectable = getInjectable({
|
|||||||
browserWindow?.close();
|
browserWindow?.close();
|
||||||
browserWindow = undefined;
|
browserWindow = undefined;
|
||||||
},
|
},
|
||||||
send: async (args: SendToViewArgs) => {
|
send: (args: SendToViewArgs) => {
|
||||||
if (!browserWindow) {
|
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);
|
return browserWindow.send(args);
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export interface SendToViewArgs {
|
|||||||
export interface LensWindow {
|
export interface LensWindow {
|
||||||
show: () => Promise<void>;
|
show: () => Promise<void>;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
send: (args: SendToViewArgs) => Promise<void>;
|
send: (args: SendToViewArgs) => void;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ const navigateForExtensionInjectable = getInjectable({
|
|||||||
(frameInfo) => frameInfo.frameId === frameId,
|
(frameInfo) => frameInfo.frameId === frameId,
|
||||||
);
|
);
|
||||||
|
|
||||||
await applicationWindow.send({
|
applicationWindow.send({
|
||||||
channel: "extension:navigate",
|
channel: "extension:navigate",
|
||||||
frameInfo,
|
frameInfo,
|
||||||
data: [extId, pageId, params],
|
data: [extId, pageId, params],
|
||||||
|
|||||||
@ -29,7 +29,7 @@ const navigateInjectable = getInjectable({
|
|||||||
? IpcRendererNavigationEvents.NAVIGATE_IN_CLUSTER
|
? IpcRendererNavigationEvents.NAVIGATE_IN_CLUSTER
|
||||||
: IpcRendererNavigationEvents.NAVIGATE_IN_APP;
|
: IpcRendererNavigationEvents.NAVIGATE_IN_APP;
|
||||||
|
|
||||||
await applicationWindow.send({
|
applicationWindow.send({
|
||||||
channel,
|
channel,
|
||||||
frameInfo,
|
frameInfo,
|
||||||
data: [url],
|
data: [url],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user