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:
parent
8889d8c70a
commit
c58f4151c9
@ -132,7 +132,12 @@ export class BaseStore<T = any> extends Singleton {
|
|||||||
broadcastIpc(msg); // send to all windows (BrowserWindow, webContents)
|
broadcastIpc(msg); // send to all windows (BrowserWindow, webContents)
|
||||||
const frames = await this.getSubFrames();
|
const frames = await this.getSubFrames();
|
||||||
frames.forEach(frameId => {
|
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,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,12 +54,13 @@ export interface IpcBroadcastParams<A extends any[] = any> {
|
|||||||
channel: IpcChannel
|
channel: IpcChannel
|
||||||
webContentId?: number; // send to single webContents view
|
webContentId?: number; // send to single webContents view
|
||||||
frameId?: number; // send to inner frame of webContents
|
frameId?: number; // send to inner frame of webContents
|
||||||
|
frameOnly?: boolean; // send message only to view with provided `frameId`
|
||||||
filter?: (webContent: WebContents) => boolean
|
filter?: (webContent: WebContents) => boolean
|
||||||
timeout?: number; // todo: add support
|
timeout?: number; // todo: add support
|
||||||
args?: A;
|
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;
|
const singleView = webContentId ? webContents.fromId(webContentId) : null;
|
||||||
let views = singleView ? [singleView] : webContents.getAllWebContents();
|
let views = singleView ? [singleView] : webContents.getAllWebContents();
|
||||||
if (filter) {
|
if (filter) {
|
||||||
@ -68,7 +69,9 @@ export function broadcastIpc({ channel, frameId, webContentId, filter, args = []
|
|||||||
views.forEach(webContent => {
|
views.forEach(webContent => {
|
||||||
const type = webContent.getType();
|
const type = webContent.getType();
|
||||||
logger.debug(`[IPC]: broadcasting "${channel}" to ${type}=${webContent.id}`, { args });
|
logger.debug(`[IPC]: broadcasting "${channel}" to ${type}=${webContent.id}`, { args });
|
||||||
webContent.send(channel, ...args);
|
if (!frameOnly) {
|
||||||
|
webContent.send(channel, ...args);
|
||||||
|
}
|
||||||
if (frameId) {
|
if (frameId) {
|
||||||
webContent.sendToFrame(frameId, channel, ...args)
|
webContent.sendToFrame(frameId, channel, ...args)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,11 +84,7 @@ export class KubeAuthProxy {
|
|||||||
protected async sendIpcLogMessage(res: KubeAuthProxyLog) {
|
protected async sendIpcLogMessage(res: KubeAuthProxyLog) {
|
||||||
const channel = `kube-auth:${this.cluster.id}`
|
const channel = `kube-auth:${this.cluster.id}`
|
||||||
logger.info(`[KUBE-AUTH]: out-channel "${channel}"`, { ...res, meta: this.cluster.getMeta() });
|
logger.info(`[KUBE-AUTH]: out-channel "${channel}"`, { ...res, meta: this.cluster.getMeta() });
|
||||||
broadcastIpc({
|
broadcastIpc({ channel: channel, args: [res] });
|
||||||
// webContentId: null, // todo: send a message only to single cluster's window
|
|
||||||
channel: channel,
|
|
||||||
args: [res],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public exit() {
|
public exit() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user