Skip to content

Commit e043b3b

Browse files
committed
fix: avatar lookup on disconnected
1 parent 7bb29f2 commit e043b3b

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

pages/lookup/[[walletAddress]].vue

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<template>
22
<div class="py-8 lg:py-16">
33
<div class="max-w-lg mx-auto flex flex-col gap-12">
4-
<h1 class="font-medium text-center text-2xl">Lookup avatar on {{ chain.name }}</h1>
4+
<div class="flex justify-center items-center gap-3">
5+
<h1 class="font-medium text-center text-2xl">Lookup avatar on</h1>
6+
<select class="select" v-model="selectedChain">
7+
<template v-for="chain in chains">
8+
<option :value="chain">{{ chain.name }}</option>
9+
</template>
10+
</select>
11+
</div>
512
<div class="flex gap-2">
613
<input class="input" type="text" placeholder="Search on address.." v-model="walletAddress">
714
<button :disabled="!isSearchValid" @click="search" class="px-6 h-14 flex gap-2 flex-nowrap justify-center items-center bg-blue-500/20 hover:bg-blue-500/25 disabled:bg-neutral-100 font-medium text-blue-500 disabled:text-neutral-400/75 rounded-2xl duration-300">Go</button>
@@ -15,16 +22,16 @@
1522

1623
<script setup>
1724
import {onMounted, ref} from "vue";
18-
import {useAccount, useConnect} from "@wagmi/vue";
25+
import {useAccount, useChains, useConnect} from "@wagmi/vue";
1926
import {isAddress, zeroAddress} from "viem";
2027
import AvatarViewer from "~/components/AvatarViewer.vue";
2128
22-
const { connect } = useConnect();
23-
const { chainId, chain } = useAccount();
29+
const { connect, isConnected } = useConnect();
2430
const {setAvatar, getAvatarInfo} = useAvatarService();
2531
const {getAvatarForAddress} = useAvatarServiceApi();
2632
const route = useRoute();
2733
const router = useRouter();
34+
const chains = useChains();
2835
2936
const IPFS_GATEWAY = "https://ipfs.io/ipfs/";
3037
@@ -33,14 +40,15 @@ const fetchedWalletAddress = ref("");
3340
const avatarInfo = ref(null);
3441
const avatarMetadata = ref(null);
3542
const imageLink = ref("");
43+
const selectedChain = ref(chains.value[0]);
3644
3745
onMounted(() => {
3846
if (walletAddress.value) {
3947
updateAvatarInfo();
4048
}
4149
});
4250
43-
watch(chainId, () => {
51+
watch(selectedChain, () => {
4452
updateAvatarInfo();
4553
});
4654
@@ -64,7 +72,7 @@ async function updateAvatarInfo() {
6472
6573
const apiRes = await getAvatarForAddress(address);
6674
67-
const chainName = chain.value.name.toLowerCase();
75+
const chainName = selectedChain.value.name.toLowerCase();
6876
6977
avatarInfo.value = {
7078
avatar: {
@@ -96,4 +104,8 @@ async function updateAvatarInfo() {
96104
.input {
97105
@apply bg-neutral-100 p-4 placeholder-neutral-300 rounded-2xl w-full;
98106
}
107+
108+
.select {
109+
@apply bg-neutral-100 p-4 placeholder-neutral-300 rounded-2xl;
110+
}
99111
</style>

0 commit comments

Comments
 (0)