mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Consolidate code for application window
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
5ac9b2aa87
commit
55d1471c10
68 files changed
+730
-387
No files matched your search
@@ -5,7 +5,6 @@
|
||||
import { getDiForUnitTesting as getRendererDi } from "../renderer/getDiForUnitTesting";
|
||||
import { getDiForUnitTesting as getMainDi } from "../main/getDiForUnitTesting";
|
||||
import { overrideIpcBridge } from "./override-ipc-bridge";
|
||||
import { runSetups } from "../common/setupable-injection-token/run-setups";
|
||||
|
||||
export const getDisForUnitTesting = (
|
||||
{ doGeneralOverrides } = { doGeneralOverrides: false },
|
||||
@@ -18,8 +17,5 @@ export const getDisForUnitTesting = (
|
||||
return {
|
||||
rendererDi,
|
||||
mainDi,
|
||||
|
||||
runSetups: () =>
|
||||
Promise.all([runSetups(rendererDi), runSetups(mainDi)]),
|
||||
};
|
||||
};
|
||||
@@ -10,6 +10,7 @@ import asyncFn from "@async-fn/jest";
|
||||
import registerIpcChannelListenerInjectable from "../renderer/app-paths/get-value-from-registered-channel/register-ipc-channel-listener.injectable";
|
||||
import type { SendToViewArgs } from "../main/start-main-application/lens-window/application-window/lens-window-injection-token";
|
||||
import sendToChannelInElectronBrowserWindowInjectable from "../main/start-main-application/lens-window/application-window/send-to-channel-in-electron-browser-window.injectable";
|
||||
import { isEmpty } from "lodash/fp";
|
||||
|
||||
|
||||
export const overrideIpcBridge = ({
|
||||
@@ -89,9 +90,15 @@ export const overrideIpcBridge = ({
|
||||
(browserWindow, { channel: channelName, data }: SendToViewArgs) => {
|
||||
const handles = rendererIpcFakeHandles.get(channelName);
|
||||
|
||||
handles.forEach((handle) => handle(...data));
|
||||
if (isEmpty(handles)) {
|
||||
throw new Error(
|
||||
`Tried to send message to channel "${channelName}" but there where no listeners. Current channels with listeners: "${[
|
||||
...rendererIpcFakeHandles.keys(),
|
||||
].join('", "')}"`,
|
||||
);
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
handles.forEach((handle) => handle(...data));
|
||||
},
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user