mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
feat: initialize API key on module import for improved async handling
- Start API key initialization immediately upon importing the HTTP API client module to ensure the init promise is created early. - Log errors during API key initialization to aid in debugging. Additionally, added a version field to the setup store for proper state hydration, aligning with the app-store pattern.
This commit is contained in:
@@ -1630,3 +1630,10 @@ export function getHttpApiClient(): HttpApiClient {
|
|||||||
}
|
}
|
||||||
return httpApiClientInstance;
|
return httpApiClientInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start API key initialization immediately when this module is imported
|
||||||
|
// This ensures the init promise is created early, even before React components mount
|
||||||
|
// The actual async work happens in the background and won't block module loading
|
||||||
|
initApiKey().catch((error) => {
|
||||||
|
console.error('[HTTP Client] Failed to initialize API key:', error);
|
||||||
|
});
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ export const useSetupStore = create<SetupState & SetupActions>()(
|
|||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: 'automaker-setup',
|
name: 'automaker-setup',
|
||||||
|
version: 1, // Add version field for proper hydration (matches app-store pattern)
|
||||||
partialize: (state) => ({
|
partialize: (state) => ({
|
||||||
isFirstRun: state.isFirstRun,
|
isFirstRun: state.isFirstRun,
|
||||||
setupComplete: state.setupComplete,
|
setupComplete: state.setupComplete,
|
||||||
|
|||||||
Reference in New Issue
Block a user