Simply implementation of sendToChannelInLensWindow

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2022-07-06 11:42:46 -04:00
1 parent 42af68d763
commit 99b1f20d17
3 files changed
+5 -5

No files matched your search

@@ -8,7 +8,7 @@ import type { ClusterFrameInfo } from "../../../../common/cluster-frames";
export interface SendToViewArgs { export interface SendToViewArgs {
channel: string; channel: string;
frameInfo?: ClusterFrameInfo; frameInfo?: ClusterFrameInfo;
data?: unknown[]; data?: unknown;
} }
export interface LensWindow { export interface LensWindow {
@@ -13,16 +13,16 @@ const sendToChannelInElectronBrowserWindowInjectable = getInjectable({
() => () =>
( (
browserWindow: BrowserWindow, browserWindow: BrowserWindow,
{ channel, frameInfo, data = [] }: SendToViewArgs, { channel, frameInfo, data }: SendToViewArgs,
) => { ) => {
if (frameInfo) { if (frameInfo) {
browserWindow.webContents.sendToFrame( browserWindow.webContents.sendToFrame(
[frameInfo.processId, frameInfo.frameId], [frameInfo.processId, frameInfo.frameId],
channel, channel,
...data, data,
); );
} else { } else {
browserWindow.webContents.send(channel, ...data); browserWindow.webContents.send(channel, data);
} }
}, },
@@ -17,7 +17,7 @@ const messageToChannelInjectable = getInjectable({
for (const window of getVisibleWindows()) { for (const window of getVisibleWindows()) {
window.send({ window.send({
channel: channel.id, channel: channel.id,
data: message !== undefined ? [message] : [], data: message,
}); });
} }
}) as MessageToChannel; }) as MessageToChannel;