11import { until , useAsyncState } from '@vueuse/core'
22import { defineStore , storeToRefs } from 'pinia'
33
4+ import { isCloud } from '@/platform/distribution/types'
45import { useSettingStore } from '@/platform/settings/settingStore'
56import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
67import { api } from '@/scripts/api'
7- import { useUserStore } from '@/stores/userStore'
8- import { isCloud } from '@/platform/distribution/types'
98import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
9+ import { useUserStore } from '@/stores/userStore'
1010
1111export const useBootstrapStore = defineStore ( 'bootstrap' , ( ) => {
1212 const settingStore = useSettingStore ( )
@@ -26,9 +26,16 @@ export const useBootstrapStore = defineStore('bootstrap', () => {
2626 { immediate : false }
2727 )
2828
29+ let storesLoaded = false
30+
31+ function loadAuthenticatedStores ( ) {
32+ if ( storesLoaded ) return
33+ storesLoaded = true
34+ void settingStore . load ( )
35+ void workflowStore . loadWorkflows ( )
36+ }
37+
2938 async function startStoreBootstrap ( ) {
30- // Defer settings and workflows if multi-user login is required
31- // (settings API requires authentication in multi-user mode)
3239 const userStore = useUserStore ( )
3340 await userStore . initialize ( )
3441
@@ -37,13 +44,11 @@ export const useBootstrapStore = defineStore('bootstrap', () => {
3744 await until ( isInitialized ) . toBe ( true )
3845 }
3946
40- // i18n can load without authentication
41- void loadI18n ( )
47+ const { needsLogin } = storeToRefs ( userStore )
48+ await until ( needsLogin ) . toBe ( false )
4249
43- if ( ! userStore . needsLogin ) {
44- void settingStore . load ( )
45- void workflowStore . loadWorkflows ( )
46- }
50+ void loadI18n ( )
51+ loadAuthenticatedStores ( )
4752 }
4853
4954 return {
0 commit comments