diff --git a/resources/js/components/App.vue b/resources/js/components/App.vue index 7af7571..55eae36 100644 --- a/resources/js/components/App.vue +++ b/resources/js/components/App.vue @@ -39,8 +39,8 @@ const initialTheme = () => { } }; -(() => { - appStore.init(); +(async () => { + await appStore.init(); initialTheme(); if (window.bootstrap?.name) { diff --git a/resources/js/components/beam/BeamsList.vue b/resources/js/components/beam/BeamsList.vue index 1785b80..180b371 100644 --- a/resources/js/components/beam/BeamsList.vue +++ b/resources/js/components/beam/BeamsList.vue @@ -464,8 +464,6 @@ const openTransactionSlide = async (transactionId: string) => { }; onMounted(async () => { - await appStore.initPromise; - useAppStore().clearInitPromise(); getBeams(); loadMoreItemsWithObserver(); events.on('transaction', openTransactionSlide); diff --git a/resources/js/components/beam/ClaimsList.vue b/resources/js/components/beam/ClaimsList.vue index 7417ebc..de8530c 100644 --- a/resources/js/components/beam/ClaimsList.vue +++ b/resources/js/components/beam/ClaimsList.vue @@ -119,7 +119,6 @@ import CollapseFilter from '~/components/CollapseFilter.vue'; import NoItems from '~/components/NoItems.vue'; import snackbar from '~/util/snackbar'; import { BeamApi } from '~/api/beam'; -import { useAppStore } from '~/store'; const isLoading = ref(true); const isPaginationLoading = ref(false); @@ -278,8 +277,6 @@ const closeModalSlide = () => { }; (async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); await getClaims(); })(); diff --git a/resources/js/components/marketplace/BidsList.vue b/resources/js/components/marketplace/BidsList.vue index c2855f0..1b0f43c 100644 --- a/resources/js/components/marketplace/BidsList.vue +++ b/resources/js/components/marketplace/BidsList.vue @@ -279,8 +279,6 @@ const closeModalSlide = () => { }; (async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); await getBids(); })(); diff --git a/resources/js/components/marketplace/ListingsList.vue b/resources/js/components/marketplace/ListingsList.vue index c23435b..186a12b 100644 --- a/resources/js/components/marketplace/ListingsList.vue +++ b/resources/js/components/marketplace/ListingsList.vue @@ -343,8 +343,6 @@ const closeModalSlide = () => { }; (async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); await getListings(); })(); diff --git a/resources/js/components/marketplace/SalesList.vue b/resources/js/components/marketplace/SalesList.vue index 8930601..7129ddc 100644 --- a/resources/js/components/marketplace/SalesList.vue +++ b/resources/js/components/marketplace/SalesList.vue @@ -279,8 +279,6 @@ const closeModalSlide = () => { }; (async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); await getSales(); })(); diff --git a/resources/js/components/pages/Collections.vue b/resources/js/components/pages/Collections.vue index eeb63ae..9c21df2 100644 --- a/resources/js/components/pages/Collections.vue +++ b/resources/js/components/pages/Collections.vue @@ -321,8 +321,6 @@ const openTransactionSlide = async (transactionId: string) => { }; (async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); await getCollections(); })(); diff --git a/resources/js/components/pages/FuelTanks.vue b/resources/js/components/pages/FuelTanks.vue index 7baaa1c..6e1b470 100644 --- a/resources/js/components/pages/FuelTanks.vue +++ b/resources/js/components/pages/FuelTanks.vue @@ -150,7 +150,6 @@ import { FuelTankApi } from '~/api/fueltank'; import { formatData } from '~/util'; import Btn from '../Btn.vue'; import { TransactionState } from '~/types/types.enums'; -import { useAppStore } from '~/store'; const isLoading = ref(true); const isPaginationLoading = ref(false); @@ -329,8 +328,6 @@ const openTransactionSlide = async (transactionId: string) => { }; (async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); await getFuelTanks(); })(); diff --git a/resources/js/components/pages/Tokens.vue b/resources/js/components/pages/Tokens.vue index 83fc11c..7619c66 100644 --- a/resources/js/components/pages/Tokens.vue +++ b/resources/js/components/pages/Tokens.vue @@ -159,7 +159,6 @@ import snackbar, { events } from '~/util/snackbar'; import FormInput from '~/components/FormInput.vue'; import NoItems from '~/components/NoItems.vue'; import Btn from '~/components/Btn.vue'; -import { useAppStore } from '~/store'; const isLoading = ref(false); const isPaginationLoading = ref(false); @@ -342,8 +341,6 @@ const openTransactionSlide = async (transactionId: string) => { }; onMounted(async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); getTokens(); loadMoreTokensWithObserver(); events.on('transaction', openTransactionSlide); diff --git a/resources/js/components/pages/Transactions.vue b/resources/js/components/pages/Transactions.vue index c02de3b..3d1f696 100644 --- a/resources/js/components/pages/Transactions.vue +++ b/resources/js/components/pages/Transactions.vue @@ -220,7 +220,6 @@ import SignTransaction from '../SignTransaction.vue'; import { TransactionApi } from '~/api/transaction'; import DropdownMenu from '../DropdownMenu.vue'; import ConfirmModal from '../ConfirmModal.vue'; -import { useAppStore } from '~/store'; const isLoading = ref(false); const isPaginationLoading = ref(false); @@ -550,8 +549,6 @@ const closeModalSlide = () => { }; (async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); getTransactions(); })(); diff --git a/resources/js/components/pages/Wallets.vue b/resources/js/components/pages/Wallets.vue index 26b8aa4..ee47934 100644 --- a/resources/js/components/pages/Wallets.vue +++ b/resources/js/components/pages/Wallets.vue @@ -133,7 +133,6 @@ import FormInput from '~/components/FormInput.vue'; import NoItems from '~/components/NoItems.vue'; import { TransactionState } from '~/types/types.enums'; import Btn from '../Btn.vue'; -import { useAppStore } from '~/store'; const isLoading = ref(false); const isPaginationLoading = ref(false); @@ -308,8 +307,6 @@ const openTransactionSlide = async (transactionId: string) => { }; onMounted(async () => { - await useAppStore().initPromise; - useAppStore().clearInitPromise(); getWallets(); loadMoreItemsWithObserver(); events.on('transaction', openTransactionSlide); diff --git a/resources/js/components/pages/auth/Login.vue b/resources/js/components/pages/auth/Login.vue index 382216e..6240209 100644 --- a/resources/js/components/pages/auth/Login.vue +++ b/resources/js/components/pages/auth/Login.vue @@ -152,9 +152,7 @@ const login = async (recaptcha?: string) => { return; } - appStore.init(); - await appStore.initPromise; - appStore.clearInitPromise(); + await appStore.init(); if (appStore.loggedIn) { snackbar.success({ title: 'Logged in successfully', save: false }); if (appStore.hasValidConfig) { diff --git a/resources/js/store/index.ts b/resources/js/store/index.ts index b4ca616..f51a10f 100644 --- a/resources/js/store/index.ts +++ b/resources/js/store/index.ts @@ -50,64 +50,60 @@ export const useAppStore = defineStore('app', { async init() { try { // eslint-disable-next-line - this.initPromise = new Promise(async (resolve) => { - if (this.config.network) { - return; - } + if (this.config.network) { + return; + } - this.setConfig(); + this.setConfig(); - if (!this.config.url) { - return false; - } - if (!this.isMultiTenant && !this.config.authorization_token.length) { - return false; - } + if (!this.config.url) { + return false; + } + if (!this.isMultiTenant && !this.config.authorization_token.length) { + return false; + } - const urlConfig = await this.checkURL(this.config.url); - try { - const internalConfig = await ApiService.fetchInternalUrl(this.config.url); - if (internalConfig) { - this.internal = true; - } - } catch { - this.internal = false; + const urlConfig = await this.checkURL(this.config.url); + try { + const internalConfig = await ApiService.fetchInternalUrl(this.config.url); + if (internalConfig) { + this.internal = true; } - this.config.network = urlConfig?.network; - this.config.packages = Object.entries(urlConfig.packages).map(([key, value]: any[]) => { - let link = - urlConfig.url + - '/graphiql/' + - (key === 'enjin/platform-core' ? '' : key.replace('enjin/platform-', '')); - if (key === 'enjin/platform-ui') link = ''; - - return { - name: key.replace('enjin/', ''), - version: value.version, - link, - }; - }); + } catch { + this.internal = false; + } + this.config.network = urlConfig?.network; + this.config.packages = Object.entries(urlConfig.packages).map(([key, value]: any[]) => { + let link = + urlConfig.url + + '/graphiql/' + + (key === 'enjin/platform-core' ? '' : key.replace('enjin/platform-', '')); + if (key === 'enjin/platform-ui') link = ''; - if (this.hasBeamPackage) { - this.addBeamNavigation(); - } - if (this.hasFuelTanksPackage) { - this.addFuelTanksNavigation(); - } - if (this.hasMarketplacePackage) { - this.addMarketplaceNavigation(); - } + return { + name: key.replace('enjin/', ''), + version: value.version, + link, + }; + }); - if (this.loggedIn && this.hasMultiTenantPackage && this.config.tenant && !this.user) { - await this.getUser(); - } + if (this.hasBeamPackage) { + this.addBeamNavigation(); + } + if (this.hasFuelTanksPackage) { + this.addFuelTanksNavigation(); + } + if (this.hasMarketplacePackage) { + this.addMarketplaceNavigation(); + } - await useConnectionStore().getSession(); + if (this.loggedIn && this.hasMultiTenantPackage && this.config.tenant && !this.user) { + await this.getUser(); + } - await this.fetchCollectionIds(); + await useConnectionStore().getSession(); - resolve(); - }); + await this.fetchCollectionIds(); } catch (error: any) { snackbar.error({ title: error }); if (this.config.tenant) {