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

cluster-view battling -- part 3

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-08-07 10:54:21 +03:00
parent aa718dd7e1
commit 0ba275b332
7 changed files with 11 additions and 23 deletions

View File

@ -3,14 +3,6 @@ import { ClusterId, clusterStore } from "./cluster-store";
import { tracker } from "./tracker";
export const clusterIpc = {
// todo: remove
init: createIpcChannel({
channel: "cluster:init",
handle: async (clusterId: ClusterId) => {
return clusterStore.getById(clusterId)?.pushState();
},
}),
activate: createIpcChannel({
channel: "cluster:activate",
handle: async (clusterId: ClusterId = clusterStore.activeClusterId) => {

View File

@ -64,7 +64,7 @@ export class ClusterStore extends BaseStore<ClusterStoreModel> {
if (ipcRenderer) {
ipcRenderer.on("cluster:state", (event, clusterState: ClusterState) => {
this.applyWithoutSync(() => {
logger.debug(`[CLUSTER-STORE]: received state update for cluster=${clusterState.id}`, clusterState);
logger.info(`[CLUSTER-STORE]: received state update for cluster=${clusterState.id}`, clusterState);
const cluster = this.getById(clusterState.id);
if (cluster) cluster.updateModel(clusterState)
})

View File

@ -33,7 +33,7 @@ export interface IpcChannelInit {
once?: boolean; // todo: add support
}
export function createIpcChannel({ autoBind = false, mode = IpcMode.ASYNC, timeout = 0, handle, channel }: IpcChannelInit) {
export function createIpcChannel({ autoBind = true, mode = IpcMode.ASYNC, timeout = 0, handle, channel }: IpcChannelInit) {
channel = `${mode}:${channel}`
const ipcChannel = {

View File

@ -1,8 +1,8 @@
import "../common/cluster-ipc";
import type http from "http"
import { autorun } from "mobx";
import { ClusterId, clusterStore } from "../common/cluster-store"
import { Cluster } from "./cluster"
import { clusterIpc } from "../common/cluster-ipc";
import logger from "./logger";
export class ClusterManager {
@ -29,13 +29,6 @@ export class ClusterManager {
}, {
delay: 250
});
// listen for ipc-events that must/can be handled *only* in main-process (nodeIntegration=true)
clusterIpc.activate.handleInMain();
clusterIpc.disconnect.handleInMain();
clusterIpc.installFeature.handleInMain();
clusterIpc.uninstallFeature.handleInMain();
clusterIpc.upgradeFeature.handleInMain();
}
stop() {

View File

@ -31,14 +31,13 @@ import { isAllowedResource } from "../../common/rbac";
import { ClusterSettings, clusterSettingsRoute } from "./+cluster-settings";
import { ErrorBoundary } from "./error-boundary";
import { Terminal } from "./dock/terminal";
import { getHostedClusterId } from "../../common/cluster-store";
import { clusterIpc } from "../../common/cluster-ipc";
import { getHostedCluster } from "../../common/cluster-store";
@observer
export class App extends React.Component {
static async init() {
await clusterIpc.init.invokeFromRenderer(getHostedClusterId())
await Terminal.preloadFonts()
await getHostedCluster().whenInitialized;
}
get startURL() {

View File

@ -44,7 +44,7 @@ export class ClusterStatus extends React.Component<Props> {
error: res.error,
});
})
await this.refreshClusterState();
// await this.refreshClusterState();
}
componentWillUnmount() {

View File

@ -39,8 +39,10 @@ export class ClusterView extends React.Component {
webview.setAttribute("src", `//${clusterId}.${location.host}`)
webview.setAttribute("nodeintegration", "true")
webview.setAttribute("enableremotemodule", "true")
// webview.addEventListener("did-start-loading", () => {
// webview.openDevTools();
// });
webview.addEventListener("did-finish-load", () => {
webview.openDevTools();
webview.classList.add("loaded");
ClusterView.isLoaded.set(clusterId, true)
});
@ -52,9 +54,11 @@ export class ClusterView extends React.Component {
}
activateView = async (clusterId: ClusterId) => {
const cluster = clusterStore.getById(clusterId);
const view = ClusterView.views.get(clusterId);
const isLoaded = ClusterView.isLoaded.has(clusterId);
if (view && isLoaded && this.placeholder) {
cluster.pushState(); // fixme
this.placeholder.replaceWith(view);
}
}