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:
parent
7207edd8f2
commit
1976ce521b
@ -62,7 +62,9 @@ const di = getDi();
|
||||
|
||||
app.setName(appName);
|
||||
|
||||
di.runSetups().then(() => {
|
||||
app.on("ready", async () => {
|
||||
await di.runSetups();
|
||||
|
||||
injectSystemCAs();
|
||||
|
||||
const onCloseCleanup = disposer();
|
||||
@ -124,7 +126,66 @@ di.runSetups().then(() => {
|
||||
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);
|
||||
|
||||
logger.info(`🚀 Starting ${productName} from "${directoryForExes}"`);
|
||||
@ -291,67 +352,6 @@ di.runSetups().then(() => {
|
||||
}, 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");
|
||||
});
|
||||
|
||||
/**
|
||||
* Exports for virtual package "@k8slens/extensions" for main-process.
|
||||
* All exporting names available in global runtime scope:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user