Skip to content

Commit

Permalink
Fix early init issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alexk111 committed Oct 11, 2024
1 parent f1ff917 commit 5af0431
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/renderer/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ function prepareDataStorageForRenderer(dataStorage: DataStorage): DataStorageRen
}

function createStore() {
const { promise: appStoreReady, resolve } = Promise.withResolvers<boolean>();

const firstRunState = createAppState();

const appState = entityStateActions.widgetTypes.setAll(firstRunState, registry.getWidgetTypes());
Expand All @@ -154,11 +156,14 @@ function createStore() {
stateStorage: createAppStateStorage(
dataStorage,
)
}, appState, () => { });
}, appState, () => {
resolve(true);
});

return {
appStore,
appStoreForUi,
appStoreReady,
} as const;
}

Expand Down Expand Up @@ -647,10 +652,12 @@ export async function init() {
const useCases = await createUseCases(store);

const { initAppMenuUseCase, initMainShortcutUseCase, initTrayMenuUseCase, initMemSaverUseCase } = useCases;
initMainShortcutUseCase();
initAppMenuUseCase();
initTrayMenuUseCase();
initMemSaverUseCase();
store.appStoreReady.then(_ => {
initMainShortcutUseCase();
initAppMenuUseCase();
initTrayMenuUseCase();
initMemSaverUseCase();
})

const stateHooks = createUiHooks(store, useCases);
const { App } = createUI(stateHooks, useCases);
Expand Down

0 comments on commit 5af0431

Please sign in to comment.