From ed99f24420c61776569b602825d5316309fbd0c5 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 1 Dec 2022 09:17:33 -0500 Subject: [PATCH] Use multiple runAfter support to fix crash on renderer Signed-off-by: Sebastian Malton --- .../stores/init-user-store.injectable.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/renderer/stores/init-user-store.injectable.ts b/src/renderer/stores/init-user-store.injectable.ts index 2c5b15dd1b..65ac9ec531 100644 --- a/src/renderer/stores/init-user-store.injectable.ts +++ b/src/renderer/stores/init-user-store.injectable.ts @@ -4,20 +4,25 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import userStoreInjectable from "../../common/user-store/user-store.injectable"; +import setupAppPathsInjectable from "../app-paths/setup-app-paths.injectable"; import { beforeFrameStartsInjectionToken } from "../before-frame-starts/before-frame-starts-injection-token"; import initDefaultUpdateChannelInjectable from "../vars/default-update-channel/init.injectable"; const initUserStoreInjectable = getInjectable({ id: "init-user-store", - instantiate: (di) => { - const userStore = di.inject(userStoreInjectable); + instantiate: (di) => ({ + id: "init-user-store", + run: () => { + // This must be done here so as to actually only be instantiated after the dependencies are + const userStore = di.inject(userStoreInjectable); - return { - id: "init-user-store", - run: () => userStore.load(), - runAfter: di.inject(initDefaultUpdateChannelInjectable), - }; - }, + return userStore.load(); + }, + runAfter: [ + di.inject(initDefaultUpdateChannelInjectable), + di.inject(setupAppPathsInjectable), + ], + }), injectionToken: beforeFrameStartsInjectionToken, });