mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
more fixes
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
81607fd57a
commit
0312da0841
@ -3,25 +3,29 @@
|
|||||||
// https://www.electronjs.org/docs/api/ipc-renderer
|
// https://www.electronjs.org/docs/api/ipc-renderer
|
||||||
|
|
||||||
import { ipcMain, ipcRenderer, remote, webContents } from "electron";
|
import { ipcMain, ipcRenderer, remote, webContents } from "electron";
|
||||||
import { toJS } from "mobx";
|
import { toJS } from "../utils/toJS";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../main/logger";
|
||||||
import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames";
|
import { ClusterFrameInfo, clusterFrameMap } from "../cluster-frames";
|
||||||
|
|
||||||
const subFramesChannel = "ipc:get-sub-frames";
|
const subFramesChannel = "ipc:get-sub-frames";
|
||||||
|
|
||||||
export function handleRequest(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any) {
|
export function handleRequest(channel: string, listener: (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any) {
|
||||||
ipcMain.handle(channel, listener);
|
ipcMain.handle(channel, async (event, ...args) => {
|
||||||
|
return toJS(await listener(event, ...args)); // make safe for ipc-messaging
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function requestMain(channel: string, ...args: any[]) {
|
export async function requestMain(channel: string, ...args: any[]) {
|
||||||
|
args = args.map(toJS); // unwrap possible observables before IPC-send
|
||||||
return ipcRenderer.invoke(channel, ...args);
|
return ipcRenderer.invoke(channel, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubFrames(): ClusterFrameInfo[] {
|
function getSubFrames(): ClusterFrameInfo[] {
|
||||||
return Array.from(toJS(clusterFrameMap).values());
|
return Array.from(clusterFrameMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function broadcastMessage(channel: string, ...args: any[]) {
|
export async function broadcastMessage(channel: string, ...args: any[]) {
|
||||||
|
args = args.map(toJS); // unwrap possible observables before IPC-send
|
||||||
const views = (webContents || remote?.webContents)?.getAllWebContents();
|
const views = (webContents || remote?.webContents)?.getAllWebContents();
|
||||||
|
|
||||||
if (!views) return;
|
if (!views) return;
|
||||||
@ -79,7 +83,5 @@ export function unsubscribeAllFromBroadcast(channel: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function bindBroadcastHandlers() {
|
export function bindBroadcastHandlers() {
|
||||||
handleRequest(subFramesChannel, () => {
|
handleRequest(subFramesChannel, () => getSubFrames());
|
||||||
return getSubFrames();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
import "./ace-editor.scss";
|
import "./ace-editor.scss";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { makeObservable } from "mobx";
|
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import AceBuild, { Ace } from "ace-builds";
|
import AceBuild, { Ace } from "ace-builds";
|
||||||
import { cssNames, noop } from "../../utils";
|
import { cssNames, noop } from "../../utils";
|
||||||
@ -45,7 +44,6 @@ export class AceEditor extends React.Component<Props, State> {
|
|||||||
|
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
super(props);
|
super(props);
|
||||||
makeObservable(this);
|
|
||||||
require("ace-builds/src-noconflict/mode-yaml");
|
require("ace-builds/src-noconflict/mode-yaml");
|
||||||
require("ace-builds/src-noconflict/theme-terminal");
|
require("ace-builds/src-noconflict/theme-terminal");
|
||||||
require("ace-builds/src-noconflict/ext-searchbox");
|
require("ace-builds/src-noconflict/ext-searchbox");
|
||||||
|
|||||||
@ -320,7 +320,7 @@ export class MenuItem extends React.Component<MenuItemProps> {
|
|||||||
return !!this.props.href;
|
return !!this.props.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick(evt: React.MouseEvent) {
|
onClick = (evt: React.MouseEvent) => {
|
||||||
const menu = this.context;
|
const menu = this.context;
|
||||||
const { spacer, onClick } = this.props;
|
const { spacer, onClick } = this.props;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user