main.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import { createApp } from 'vue'
  3. import initializeApp from '@mobile/initialize'
  4. import App from '@mobile/App.vue'
  5. import { useSessionStore } from '@shared/stores/session'
  6. import initializeStoreSubscriptions from '@shared/initializer/storeSubscriptions'
  7. import { useApplicationStore } from '@shared/stores/application'
  8. import { useLocaleStore } from '@shared/stores/locale'
  9. import initializeApolloClient from '@mobile/server/apollo'
  10. import initializeRouter from '@mobile/router'
  11. import { useAuthenticationStore } from '@shared/stores/authentication'
  12. export default async function mountApp(): Promise<void> {
  13. const app = createApp(App)
  14. initializeApp(app)
  15. initializeRouter(app)
  16. initializeApolloClient(app)
  17. initializeStoreSubscriptions()
  18. const session = useSessionStore()
  19. await session.checkSession()
  20. const application = useApplicationStore()
  21. const initalizeAfterSessionCheck: Array<Promise<unknown>> = [
  22. application.getConfig(),
  23. ]
  24. if (session.id) {
  25. useAuthenticationStore().authenticated = true
  26. initalizeAfterSessionCheck.push(session.getCurrentUser())
  27. }
  28. await Promise.all(initalizeAfterSessionCheck)
  29. const locale = useLocaleStore()
  30. if (!locale.localeData) {
  31. await locale.setLocale()
  32. }
  33. app.mount('#app')
  34. }