mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make UserStore loading seperate from creation to fix initialization timing errors
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
27e2915cb3
commit
8c6999bd60
@ -20,6 +20,7 @@ const initializeSentryReportingWithInjectable = getInjectable({
|
||||
instantiate: (di): InitializeSentryReportingWith => {
|
||||
const sentryDataSourceName = di.inject(sentryDataSourceNameInjectable);
|
||||
const isProduction = di.inject(isProductionInjectable);
|
||||
const userStore = di.inject(userStoreInjectable);
|
||||
|
||||
if (!sentryDataSourceName) {
|
||||
return () => {};
|
||||
@ -27,9 +28,6 @@ const initializeSentryReportingWithInjectable = getInjectable({
|
||||
|
||||
return (initSentry) => initSentry({
|
||||
beforeSend: (event) => {
|
||||
// TODO: remove loading from userStoreInjectable so that this can be moved out
|
||||
const userStore = di.inject(userStoreInjectable);
|
||||
|
||||
if (userStore.allowErrorReporting) {
|
||||
return event;
|
||||
}
|
||||
|
||||
@ -34,7 +34,6 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
});
|
||||
|
||||
makeObservable(this);
|
||||
this.load();
|
||||
}
|
||||
|
||||
@observable lastSeenAppVersion = "0.0.0";
|
||||
|
||||
23
src/main/stores/init-user-store.injectable.ts
Normal file
23
src/main/stores/init-user-store.injectable.ts
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
||||
import { beforeApplicationIsLoadingInjectionToken } from "../start-main-application/runnable-tokens/before-application-is-loading-injection-token";
|
||||
import initDefaultUpdateChannelInjectableInjectable from "../vars/default-update-channel/init.injectable";
|
||||
|
||||
const initUserStoreInjectable = getInjectable({
|
||||
id: "init-user-store",
|
||||
instantiate: (di) => {
|
||||
const userStore = di.inject(userStoreInjectable);
|
||||
|
||||
return {
|
||||
run: () => userStore.load(),
|
||||
runAfter: di.inject(initDefaultUpdateChannelInjectableInjectable),
|
||||
};
|
||||
},
|
||||
injectionToken: beforeApplicationIsLoadingInjectionToken,
|
||||
});
|
||||
|
||||
export default initUserStoreInjectable;
|
||||
@ -28,7 +28,6 @@ import extensionLoaderInjectable from "../extensions/extension-loader/extension-
|
||||
import extensionDiscoveryInjectable from "../extensions/extension-discovery/extension-discovery.injectable";
|
||||
import extensionInstallationStateStoreInjectable from "../extensions/extension-installation-state-store/extension-installation-state-store.injectable";
|
||||
import clusterStoreInjectable from "../common/cluster-store/cluster-store.injectable";
|
||||
import userStoreInjectable from "../common/user-store/user-store.injectable";
|
||||
import initRootFrameInjectable from "./frames/root-frame/init-root-frame/init-root-frame.injectable";
|
||||
import initClusterFrameInjectable from "./frames/cluster-frame/init-cluster-frame/init-cluster-frame.injectable";
|
||||
import commandOverlayInjectable from "./components/command-palette/command-overlay.injectable";
|
||||
@ -92,9 +91,6 @@ export async function bootstrap(di: DiContainer) {
|
||||
*/
|
||||
di.inject(autoRegistrationInjectable);
|
||||
|
||||
// TODO: Remove temporal dependencies to make timing of initialization not important
|
||||
di.inject(userStoreInjectable);
|
||||
|
||||
await attachChromeDebugger();
|
||||
rootElem.classList.toggle("is-mac", isMac);
|
||||
|
||||
|
||||
23
src/renderer/stores/init-user-store.injectable.ts
Normal file
23
src/renderer/stores/init-user-store.injectable.ts
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
||||
import { beforeFrameStartsInjectionToken } from "../before-frame-starts/before-frame-starts-injection-token";
|
||||
import initDefaultUpdateChannelInjectableInjectable from "../vars/default-update-channel/init.injectable";
|
||||
|
||||
const initUserStoreInjectable = getInjectable({
|
||||
id: "init-user-store",
|
||||
instantiate: (di) => {
|
||||
const userStore = di.inject(userStoreInjectable);
|
||||
|
||||
return {
|
||||
run: () => userStore.load(),
|
||||
runAfter: di.inject(initDefaultUpdateChannelInjectableInjectable),
|
||||
};
|
||||
},
|
||||
injectionToken: beforeFrameStartsInjectionToken,
|
||||
});
|
||||
|
||||
export default initUserStoreInjectable;
|
||||
Loading…
Reference in New Issue
Block a user