mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Stop using @electron/remote to obtain app.getPath() (#4078)
* Stop using remote to obtain app.getPath() - Initialize entire map in bootstrap() - Updated unit tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Resolve PR comments Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix test Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix build Signed-off-by: Sebastian Malton <sebastian@malton.name> * Ensure that init can only be called once and catch errors Signed-off-by: Sebastian Malton <sebastian@malton.name> * Replace basically all uses of app.getPath() with AppPaths.get() Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix unit tests Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
65b6908bf1
commit
f297407156
45 files changed
+521
-200
No files matched your search
@@ -36,8 +36,6 @@ import { ClusterStore } from "../common/cluster-store";
|
||||
import { UserStore } from "../common/user-store";
|
||||
import { ExtensionDiscovery } from "../extensions/extension-discovery";
|
||||
import { ExtensionLoader } from "../extensions/extension-loader";
|
||||
import { App } from "./components/app";
|
||||
import { LensApp } from "./lens-app";
|
||||
import { HelmRepoManager } from "../main/helm/helm-repo-manager";
|
||||
import { ExtensionInstallationStateStore } from "./components/+extensions/extension-install.store";
|
||||
import { DefaultProps } from "./mui-base-theme";
|
||||
@@ -51,6 +49,7 @@ import { ThemeStore } from "./theme.store";
|
||||
import { SentryInit } from "../common/sentry";
|
||||
import { TerminalStore } from "./components/dock/terminal.store";
|
||||
import cloudsMidnight from "./monaco-themes/Clouds Midnight.json";
|
||||
import { AppPaths } from "../common/app-paths";
|
||||
|
||||
configurePackages();
|
||||
|
||||
@@ -69,7 +68,8 @@ type AppComponent = React.ComponentType & {
|
||||
init?(rootElem: HTMLElement): Promise<void>;
|
||||
};
|
||||
|
||||
export async function bootstrap(App: AppComponent) {
|
||||
export async function bootstrap(comp: () => Promise<AppComponent>) {
|
||||
await AppPaths.init();
|
||||
const rootElem = document.getElementById("app");
|
||||
|
||||
await attachChromeDebugger();
|
||||
@@ -124,9 +124,10 @@ export async function bootstrap(App: AppComponent) {
|
||||
cs.registerIpcListener();
|
||||
|
||||
// init app's dependencies if any
|
||||
if (App.init) {
|
||||
await App.init(rootElem);
|
||||
}
|
||||
const App = await comp();
|
||||
|
||||
await App.init(rootElem);
|
||||
|
||||
render(<>
|
||||
{isMac && <div id="draggable-top" />}
|
||||
{DefaultProps(App)}
|
||||
@@ -134,7 +135,11 @@ export async function bootstrap(App: AppComponent) {
|
||||
}
|
||||
|
||||
// run
|
||||
bootstrap(process.isMainFrame ? LensApp : App);
|
||||
bootstrap(
|
||||
async () => process.isMainFrame
|
||||
? (await import("./lens-app")).LensApp
|
||||
: (await import("./components/app")).App
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user