mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
switch to event emitting renderer being ready
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
7395d0c343
commit
311178f8d7
@ -4,6 +4,7 @@ import { isDevelopment, isTestEnv } from "../common/vars";
|
|||||||
import { delay } from "../common/utils";
|
import { delay } from "../common/utils";
|
||||||
import { areArgsUpdateAvailableToBackchannel, AutoUpdateLogPrefix, broadcastMessage, onceCorrect, UpdateAvailableChannel, UpdateAvailableToBackchannel } from "../common/ipc";
|
import { areArgsUpdateAvailableToBackchannel, AutoUpdateLogPrefix, broadcastMessage, onceCorrect, UpdateAvailableChannel, UpdateAvailableToBackchannel } from "../common/ipc";
|
||||||
import { ipcMain } from "electron";
|
import { ipcMain } from "electron";
|
||||||
|
import { once } from "lodash";
|
||||||
|
|
||||||
function handleAutoUpdateBackChannel(event: Electron.IpcMainEvent, ...[arg]: UpdateAvailableToBackchannel) {
|
function handleAutoUpdateBackChannel(event: Electron.IpcMainEvent, ...[arg]: UpdateAvailableToBackchannel) {
|
||||||
if (arg.doUpdate) {
|
if (arg.doUpdate) {
|
||||||
@ -27,7 +28,7 @@ function handleAutoUpdateBackChannel(event: Electron.IpcMainEvent, ...[arg]: Upd
|
|||||||
* starts the automatic update checking
|
* starts the automatic update checking
|
||||||
* @param interval milliseconds between interval to check on, defaults to 24h
|
* @param interval milliseconds between interval to check on, defaults to 24h
|
||||||
*/
|
*/
|
||||||
export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void {
|
export const startUpdateChecking = once(function (interval = 1000 * 60 * 60 * 24): void {
|
||||||
if (isDevelopment || isTestEnv) {
|
if (isDevelopment || isTestEnv) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -65,7 +66,7 @@ export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
helper();
|
helper();
|
||||||
}
|
});
|
||||||
|
|
||||||
export async function checkForUpdates(): Promise<void> {
|
export async function checkForUpdates(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import "../common/system-ca";
|
|||||||
import "../common/prometheus-providers";
|
import "../common/prometheus-providers";
|
||||||
import * as Mobx from "mobx";
|
import * as Mobx from "mobx";
|
||||||
import * as LensExtensions from "../extensions/core-api";
|
import * as LensExtensions from "../extensions/core-api";
|
||||||
import { app, dialog, powerMonitor } from "electron";
|
import { app, dialog, ipcMain, powerMonitor } from "electron";
|
||||||
import { appName } from "../common/vars";
|
import { appName } from "../common/vars";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { LensProxy } from "./lens-proxy";
|
import { LensProxy } from "./lens-proxy";
|
||||||
@ -146,12 +146,14 @@ app.on("ready", async () => {
|
|||||||
|
|
||||||
logger.info("🖥️ Starting WindowManager");
|
logger.info("🖥️ Starting WindowManager");
|
||||||
windowManager = WindowManager.getInstance<WindowManager>(proxyPort);
|
windowManager = WindowManager.getInstance<WindowManager>(proxyPort);
|
||||||
windowManager.whenLoaded.then(() => {
|
|
||||||
|
ipcMain.on("renderer:loaded", () => {
|
||||||
startUpdateChecking();
|
startUpdateChecking();
|
||||||
LensProtocolRouterMain
|
LensProtocolRouterMain
|
||||||
.getInstance<LensProtocolRouterMain>()
|
.getInstance<LensProtocolRouterMain>()
|
||||||
.rendererLoaded = true;
|
.rendererLoaded = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
extensionLoader.whenLoaded.then(() => {
|
extensionLoader.whenLoaded.then(() => {
|
||||||
LensProtocolRouterMain
|
LensProtocolRouterMain
|
||||||
.getInstance<LensProtocolRouterMain>()
|
.getInstance<LensProtocolRouterMain>()
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type { ClusterId } from "../common/cluster-store";
|
import type { ClusterId } from "../common/cluster-store";
|
||||||
import { observable, when } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { app, BrowserWindow, dialog, shell, webContents } from "electron";
|
import { app, BrowserWindow, dialog, shell, webContents } from "electron";
|
||||||
import windowStateKeeper from "electron-window-state";
|
import windowStateKeeper from "electron-window-state";
|
||||||
import { appEventBus } from "../common/event-bus";
|
import { appEventBus } from "../common/event-bus";
|
||||||
@ -16,16 +16,6 @@ export class WindowManager extends Singleton {
|
|||||||
protected windowState: windowStateKeeper.State;
|
protected windowState: windowStateKeeper.State;
|
||||||
protected disposers: Record<string, Function> = {};
|
protected disposers: Record<string, Function> = {};
|
||||||
|
|
||||||
/**
|
|
||||||
* This will transition from `false` -> `true` when the main view has loaded
|
|
||||||
* the renderer URL and has been shown successfully.
|
|
||||||
*
|
|
||||||
* This is useful for waiting until the renderer is ready before trying to
|
|
||||||
* send requests to it (such as the protocol router)
|
|
||||||
*/
|
|
||||||
@observable mainViewInitiallyLoaded = false;
|
|
||||||
whenLoaded = when(() => this.mainViewInitiallyLoaded);
|
|
||||||
|
|
||||||
@observable activeClusterId: ClusterId;
|
@observable activeClusterId: ClusterId;
|
||||||
|
|
||||||
constructor(protected proxyPort: number) {
|
constructor(protected proxyPort: number) {
|
||||||
@ -111,7 +101,6 @@ export class WindowManager extends Singleton {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
appEventBus.emit({ name: "app", action: "start" });
|
appEventBus.emit({ name: "app", action: "start" });
|
||||||
}, 1000);
|
}, 1000);
|
||||||
this.mainViewInitiallyLoaded = true;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
dialog.showErrorBox("ERROR!", err.toString());
|
dialog.showErrorBox("ERROR!", err.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { broadcastMessage } from "../common/ipc";
|
|||||||
import { CommandContainer } from "./components/command-palette/command-container";
|
import { CommandContainer } from "./components/command-palette/command-container";
|
||||||
import { LensProtocolRouterRenderer } from "./protocol-handler/router";
|
import { LensProtocolRouterRenderer } from "./protocol-handler/router";
|
||||||
import { registerIpcHandlers } from "./ipc";
|
import { registerIpcHandlers } from "./ipc";
|
||||||
|
import { ipcRenderer } from "electron";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class LensApp extends React.Component {
|
export class LensApp extends React.Component {
|
||||||
@ -28,6 +29,7 @@ export class LensApp extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
registerIpcHandlers();
|
registerIpcHandlers();
|
||||||
|
ipcRenderer.emit("renderer:loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user