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

fix: don't repeat ipc-sync message to main renderer process/window when sending to frames

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-08-21 14:03:10 +03:00
parent 8889d8c70a
commit c58f4151c9
3 changed files with 12 additions and 8 deletions

View File

@ -132,7 +132,12 @@ export class BaseStore<T = any> extends Singleton {
broadcastIpc(msg); // send to all windows (BrowserWindow, webContents)
const frames = await this.getSubFrames();
frames.forEach(frameId => {
broadcastIpc({ frameId, ...msg }); // send to all sub-frames (e.g. cluster-view managed in iframe)
// send to all sub-frames (e.g. cluster-view managed in iframe)
broadcastIpc({
...msg,
frameId: frameId,
frameOnly: true,
});
});
}

View File

@ -54,12 +54,13 @@ export interface IpcBroadcastParams<A extends any[] = any> {
channel: IpcChannel
webContentId?: number; // send to single webContents view
frameId?: number; // send to inner frame of webContents
frameOnly?: boolean; // send message only to view with provided `frameId`
filter?: (webContent: WebContents) => boolean
timeout?: number; // todo: add support
args?: A;
}
export function broadcastIpc({ channel, frameId, webContentId, filter, args = [] }: IpcBroadcastParams) {
export function broadcastIpc({ channel, frameId, frameOnly, webContentId, filter, args = [] }: IpcBroadcastParams) {
const singleView = webContentId ? webContents.fromId(webContentId) : null;
let views = singleView ? [singleView] : webContents.getAllWebContents();
if (filter) {
@ -68,7 +69,9 @@ export function broadcastIpc({ channel, frameId, webContentId, filter, args = []
views.forEach(webContent => {
const type = webContent.getType();
logger.debug(`[IPC]: broadcasting "${channel}" to ${type}=${webContent.id}`, { args });
webContent.send(channel, ...args);
if (!frameOnly) {
webContent.send(channel, ...args);
}
if (frameId) {
webContent.sendToFrame(frameId, channel, ...args)
}

View File

@ -84,11 +84,7 @@ export class KubeAuthProxy {
protected async sendIpcLogMessage(res: KubeAuthProxyLog) {
const channel = `kube-auth:${this.cluster.id}`
logger.info(`[KUBE-AUTH]: out-channel "${channel}"`, { ...res, meta: this.cluster.getMeta() });
broadcastIpc({
// webContentId: null, // todo: send a message only to single cluster's window
channel: channel,
args: [res],
});
broadcastIpc({ channel: channel, args: [res] });
}
public exit() {