Make UserStore loading seperate from creation to fix initialization timing errors

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2022-09-19 10:54:15 -04:00
1 parent 27e2915cb3
commit 8c6999bd60
5 files changed
+47 -8

No files matched your search

@@ -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;
}
-1
View File
@@ -34,7 +34,6 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
});
makeObservable(this);
this.load();
}
@observable lastSeenAppVersion = "0.0.0";
@@ -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;
-4
View File
@@ -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);
@@ -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;