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

run di.runSetups() after app is ready

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2022-03-11 08:47:18 +02:00
parent 7207edd8f2
commit 1976ce521b

View File

@ -62,7 +62,9 @@ const di = getDi();
app.setName(appName); app.setName(appName);
di.runSetups().then(() => { app.on("ready", async () => {
await di.runSetups();
injectSystemCAs(); injectSystemCAs();
const onCloseCleanup = disposer(); const onCloseCleanup = disposer();
@ -124,7 +126,66 @@ di.runSetups().then(() => {
WindowManager.getInstance(false)?.ensureMainWindow(); WindowManager.getInstance(false)?.ensureMainWindow();
}); });
app.on("ready", async () => { app.on("activate", (event, hasVisibleWindows) => {
logger.info("APP:ACTIVATE", { hasVisibleWindows });
if (!hasVisibleWindows) {
WindowManager.getInstance(false)?.ensureMainWindow(false);
}
});
/**
* This variable should is used so that `autoUpdater.installAndQuit()` works
*/
let blockQuit = !isIntegrationTesting;
autoUpdater.on("before-quit-for-update", () => {
logger.debug("Unblocking quit for update");
blockQuit = false;
});
app.on("will-quit", (event) => {
logger.debug("will-quit message");
// This is called when the close button of the main window is clicked
logger.info("APP:QUIT");
appEventBus.emit({ name: "app", action: "close" });
ClusterManager.getInstance(false)?.stop(); // close cluster connections
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
kubeConfigSyncManager.stopSync();
onCloseCleanup();
// This is set to false here so that LPRM can wait to send future lens://
// requests until after it loads again
lensProtocolRouterMain.rendererLoaded = false;
if (blockQuit) {
// Quit app on Cmd+Q (MacOS)
event.preventDefault(); // prevent app's default shutdown (e.g. required for telemetry, etc.)
return; // skip exit to make tray work, to quit go to app's global menu or tray's menu
}
lensProtocolRouterMain.cleanup();
onQuitCleanup();
});
app.on("open-url", (event, rawUrl) => {
logger.debug("open-url message");
// lens:// protocol handler
event.preventDefault();
lensProtocolRouterMain.route(rawUrl);
});
logger.debug("[APP-MAIN] waiting for 'ready' and other messages");
const directoryForExes = di.inject(directoryForExesInjectable); const directoryForExes = di.inject(directoryForExesInjectable);
logger.info(`🚀 Starting ${productName} from "${directoryForExes}"`); logger.info(`🚀 Starting ${productName} from "${directoryForExes}"`);
@ -289,67 +350,6 @@ di.runSetups().then(() => {
setTimeout(() => { setTimeout(() => {
appEventBus.emit({ name: "service", action: "start" }); appEventBus.emit({ name: "service", action: "start" });
}, 1000); }, 1000);
});
app.on("activate", (event, hasVisibleWindows) => {
logger.info("APP:ACTIVATE", { hasVisibleWindows });
if (!hasVisibleWindows) {
WindowManager.getInstance(false)?.ensureMainWindow(false);
}
});
/**
* This variable should is used so that `autoUpdater.installAndQuit()` works
*/
let blockQuit = !isIntegrationTesting;
autoUpdater.on("before-quit-for-update", () => {
logger.debug("Unblocking quit for update");
blockQuit = false;
});
app.on("will-quit", (event) => {
logger.debug("will-quit message");
// This is called when the close button of the main window is clicked
logger.info("APP:QUIT");
appEventBus.emit({ name: "app", action: "close" });
ClusterManager.getInstance(false)?.stop(); // close cluster connections
const kubeConfigSyncManager = di.inject(kubeconfigSyncManagerInjectable);
kubeConfigSyncManager.stopSync();
onCloseCleanup();
// This is set to false here so that LPRM can wait to send future lens://
// requests until after it loads again
lensProtocolRouterMain.rendererLoaded = false;
if (blockQuit) {
// Quit app on Cmd+Q (MacOS)
event.preventDefault(); // prevent app's default shutdown (e.g. required for telemetry, etc.)
return; // skip exit to make tray work, to quit go to app's global menu or tray's menu
}
lensProtocolRouterMain.cleanup();
onQuitCleanup();
});
app.on("open-url", (event, rawUrl) => {
logger.debug("open-url message");
// lens:// protocol handler
event.preventDefault();
lensProtocolRouterMain.route(rawUrl);
});
logger.debug("[APP-MAIN] waiting for 'ready' and other messages");
}); });
/** /**