diff --git a/app.vue b/app.vue index 4a53d95fa..9cecc6b5f 100644 --- a/app.vue +++ b/app.vue @@ -39,13 +39,16 @@ import { storeToRefs } from 'pinia' import { useBookStoreApiStore } from '~/stores/book-store-api' +import { useCollectionStore } from '~/stores/collection' import { useUIStore } from '~/stores/ui' const { SITE_URL } = useRuntimeConfig().public const bookStoreApiStore = useBookStoreApiStore() +const collectionStore = useCollectionStore() -const { restoreAuthSession } = bookStoreApiStore -const { isRestoringSession } = storeToRefs(bookStoreApiStore) +const { restoreAuthSession, fetchBookListing } = bookStoreApiStore +const { listNFTBookCollections } = collectionStore +const { isRestoringSession, isAuthenticated } = storeToRefs(bookStoreApiStore) const uiStore = useUIStore() const isMobileMenuOpen = computed({ @@ -93,6 +96,12 @@ useSeoMeta({ onMounted(async () => { await restoreAuthSession() + if (isAuthenticated.value) { + await Promise.all([ + fetchBookListing(), + listNFTBookCollections() + ]) + } }) diff --git a/components/SiteMenu.vue b/components/SiteMenu.vue index d26b1ca5b..0d2bac4b4 100644 --- a/components/SiteMenu.vue +++ b/components/SiteMenu.vue @@ -37,7 +37,15 @@ diff --git a/composables/useAuth.ts b/composables/useAuth.ts index b0cc89228..8a2da6e63 100644 --- a/composables/useAuth.ts +++ b/composables/useAuth.ts @@ -2,13 +2,16 @@ import { ref } from 'vue' import { storeToRefs } from 'pinia' import { useWalletStore } from '~/stores/wallet' import { useBookStoreApiStore } from '~/stores/book-store-api' +import { useCollectionStore } from '~/stores/collection' export function useAuth () { const bookStoreApiStore = useBookStoreApiStore() + const collectionStore = useCollectionStore() const store = useWalletStore() const { wallet, signer } = storeToRefs(store) const { disconnect, signMessageMemo, openConnectWalletModal, initWallet } = store - const { authenticate, clearSession } = bookStoreApiStore + const { authenticate, clearSession, fetchBookListing } = bookStoreApiStore + const { listNFTBookCollections } = collectionStore const toast = useToast() const isAuthenticating = ref(false) @@ -36,6 +39,10 @@ export function useAuth () { } await authenticate(wallet.value, signature) + await Promise.all([ + fetchBookListing(), + listNFTBookCollections() + ]) } catch (err) { disconnect() clearSession() diff --git a/pages/nft-book-store/collection/status/[collectionId].vue b/pages/nft-book-store/collection/status/[collectionId].vue index 48081b335..96a594468 100644 --- a/pages/nft-book-store/collection/status/[collectionId].vue +++ b/pages/nft-book-store/collection/status/[collectionId].vue @@ -445,7 +445,7 @@ const collectionStore = useCollectionStore() const stripeStore = useStripeStore() const { token } = storeToRefs(bookStoreApiStore) const { wallet } = storeToRefs(store) -const { updateNFTBookCollectionById } = collectionStore +const { updateNFTBookCollectionById, reduceListingPendingNFTCountById } = collectionStore const { getClassMetadataById, lazyFetchClassMetadataById } = nftStore const { fetchStripeConnectStatusByWallet } = stripeStore @@ -868,7 +868,8 @@ async function hardSetStatusToCompleted (purchase: any) { } if (previousStatus === 'pendingNFT') { - collectionListingInfo.value.pendingNFTCount -= 1 + collectionListingInfo.value.pendingNFTCount -= 11 + reduceListingPendingNFTCountById(collectionId.value, 1) } } diff --git a/pages/nft-book-store/index.vue b/pages/nft-book-store/index.vue index 081c899bf..7a7d91838 100644 --- a/pages/nft-book-store/index.vue +++ b/pages/nft-book-store/index.vue @@ -158,23 +158,18 @@