From 3f0185150f2b356e91b1e6a172ad8bc7a654029e Mon Sep 17 00:00:00 2001 From: Lionell Briones Date: Wed, 8 Jan 2025 15:32:46 +0800 Subject: [PATCH] fix connectedAdapterName not being updated --- .../src/components/AppDashboard.vue | 53 ++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/demo/vue-app-new/src/components/AppDashboard.vue b/demo/vue-app-new/src/components/AppDashboard.vue index e5c4a2859..885cea4ac 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,18 @@ 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(() => { + 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 && connectedAdapterName.value === WALLET_ADAPTERS.AUTH, + nftCheckoutServices: formData.chainNamespace === CHAIN_NAMESPACES.EIP155 && formData.nftCheckoutPlugin.enable, + }; +}); const clearConsole = () => { const el = document.querySelector("#console>pre"); @@ -209,10 +196,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; + }); +});