From ca49e585e7d9cf61d104e8fddfad0a30ec0fa0c4 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 5 Dec 2022 14:32:38 -0500 Subject: [PATCH] Fix HotbarStore.load being called twice is being buggy Signed-off-by: Sebastian Malton --- src/common/hotbars/store.ts | 2 +- .../hotbar/store/main/init.injectable.ts | 8 +++--- .../setup-hotbar-store.injectable.ts | 27 ------------------- 3 files changed, 5 insertions(+), 32 deletions(-) delete mode 100644 src/main/start-main-application/runnables/setup-hotbar-store.injectable.ts diff --git a/src/common/hotbars/store.ts b/src/common/hotbars/store.ts index 7a08a1c057..cfed5efd4f 100644 --- a/src/common/hotbars/store.ts +++ b/src/common/hotbars/store.ts @@ -100,7 +100,7 @@ export class HotbarStore extends BaseStore { this._activeHotbarId = data.activeHotbarId; } - if (!this.activeHotbarId) { + if (!this._activeHotbarId) { this._activeHotbarId = this.hotbars[0].id; } } diff --git a/src/features/hotbar/store/main/init.injectable.ts b/src/features/hotbar/store/main/init.injectable.ts index 29d8497387..0717151b53 100644 --- a/src/features/hotbar/store/main/init.injectable.ts +++ b/src/features/hotbar/store/main/init.injectable.ts @@ -4,8 +4,8 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import hotbarStoreInjectable from "../../../../common/hotbars/store.injectable"; -import { beforeApplicationIsLoadingInjectionToken } from "../../../../main/start-main-application/runnable-tokens/before-application-is-loading-injection-token"; -import initClusterStoreInjectable from "../../../cluster/store/main/init.injectable"; +import { onLoadOfApplicationInjectionToken } from "../../../../main/start-main-application/runnable-tokens/on-load-of-application-injection-token"; +import setupSyncingOfGeneralCatalogEntitiesInjectable from "../../../../main/start-main-application/runnables/setup-syncing-of-general-catalog-entities.injectable"; const initHotbarStoreInjectable = getInjectable({ id: "init-hotbar-store", @@ -17,10 +17,10 @@ const initHotbarStoreInjectable = getInjectable({ run: () => { hotbarStore.load(); }, - runAfter: di.inject(initClusterStoreInjectable), + runAfter: di.inject(setupSyncingOfGeneralCatalogEntitiesInjectable), }; }, - injectionToken: beforeApplicationIsLoadingInjectionToken, + injectionToken: onLoadOfApplicationInjectionToken, }); export default initHotbarStoreInjectable; diff --git a/src/main/start-main-application/runnables/setup-hotbar-store.injectable.ts b/src/main/start-main-application/runnables/setup-hotbar-store.injectable.ts deleted file mode 100644 index 4f46e46073..0000000000 --- a/src/main/start-main-application/runnables/setup-hotbar-store.injectable.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * 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 setupSyncingOfGeneralCatalogEntitiesInjectable from "./setup-syncing-of-general-catalog-entities.injectable"; -import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/on-load-of-application-injection-token"; -import hotbarStoreInjectable from "../../../common/hotbars/store.injectable"; - -const setupHotbarStoreInjectable = getInjectable({ - id: "setup-hotbar-store", - - instantiate: (di) => ({ - id: "setup-hotbar-store", - run: () => { - const hotbarStore = di.inject(hotbarStoreInjectable); - - hotbarStore.load(); - }, - - runAfter: di.inject(setupSyncingOfGeneralCatalogEntitiesInjectable), - }), - - injectionToken: onLoadOfApplicationInjectionToken, -}); - -export default setupHotbarStoreInjectable;