diff --git a/demo/vue-app-new/src/components/AppDashboard.vue b/demo/vue-app-new/src/components/AppDashboard.vue index e5c4a2859..edd415491 100644 --- a/demo/vue-app-new/src/components/AppDashboard.vue +++ b/demo/vue-app-new/src/components/AppDashboard.vue @@ -4,6 +4,7 @@ import { CHAIN_NAMESPACES, IProvider, log, WALLET_ADAPTERS, WALLET_PLUGINS } fro import { useWeb3Auth } from "@web3auth/modal-vue-composables"; import { NFTCheckoutPlugin } from "@web3auth/nft-checkout-plugin"; import { WalletServicesPlugin } from "@web3auth/wallet-services-plugin"; +import { computed, onMounted, ref } from "vue"; import { useI18n } from "vue-i18n"; import { NFT_CHECKOUT_CONTRACT_ID } from "../config"; @@ -27,32 +28,19 @@ const formData = formDataStore; const { userInfo, isConnected, provider, switchChain, addAndSwitchChain, web3Auth } = useWeb3Auth(); -const isDisplay = (name: string): boolean => { - switch (name) { - case "dashboard": - return isConnected.value; +const connectedAdapterName = ref(""); - case "ethServices": - return formData.chainNamespace === CHAIN_NAMESPACES.EIP155; - - case "solServices": - return formData.chainNamespace === CHAIN_NAMESPACES.SOLANA; - - case "walletServices": - return ( - formData.chainNamespace === CHAIN_NAMESPACES.EIP155 && - formData.walletPlugin.enable && - web3Auth.value?.connectedAdapterName === WALLET_ADAPTERS.AUTH - ); - - case "nftCheckoutServices": - return formData.chainNamespace === CHAIN_NAMESPACES.EIP155 && formData.nftCheckoutPlugin.enable; - - default: { - return false; - } - } -}; +const isDisplay = computed(() => { + const finalConnectedAdapterName = connectedAdapterName.value || web3Auth.value?.connectedAdapterName; + return { + dashboard: isConnected.value, + ethServices: formData.chainNamespace === CHAIN_NAMESPACES.EIP155, + solServices: formData.chainNamespace === CHAIN_NAMESPACES.SOLANA, + walletServices: + formData.chainNamespace === CHAIN_NAMESPACES.EIP155 && formData.walletPlugin.enable && finalConnectedAdapterName === WALLET_ADAPTERS.AUTH, + nftCheckoutServices: formData.chainNamespace === CHAIN_NAMESPACES.EIP155 && formData.nftCheckoutPlugin.enable, + }; +}); const clearConsole = () => { const el = document.querySelector("#console>pre"); @@ -209,10 +197,16 @@ const onSignTypedData_v4 = async () => { const onSignPersonalMsg = async () => { await signPersonalMessage(provider.value as IProvider, printToConsole); }; + +onMounted(() => { + web3Auth.value?.on("connected", (data) => { + connectedAdapterName.value = data.adapter; + }); +});