Skip to content

Commit c114f8d

Browse files
committedJun 15, 2024·
feat: add network query param to lookup page
1 parent 0bcabbf commit c114f8d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed
 

‎pages/lookup/[[walletAddress]].vue

+18-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ const selectedChain = ref(chains.value[0]);
4545
const isGettingAvatar = ref(false);
4646
4747
onMounted(() => {
48-
if (accountChain.value) {
48+
if (route.query?.network) {
49+
selectChainByName(route.query?.network);
50+
} else if (accountChain.value) {
4951
selectedChain.value = accountChain.value;
5052
}
5153
@@ -61,16 +63,30 @@ watch(accountChain, () => {
6163
});
6264
6365
watch(selectedChain, () => {
66+
router.push({
67+
params: { walletAddress: walletAddress.value },
68+
query: { network: selectedChain.value.name.toLowerCase() }
69+
});
70+
6471
updateAvatarInfo();
6572
});
6673
6774
const isSearchValid = computed(() => {
6875
return walletAddress.value && isAddress(walletAddress.value) && walletAddress.value !== fetchedWalletAddress.value && !isGettingAvatar.value;
6976
});
7077
78+
function selectChainByName(name) {
79+
for (const chain of chains.value) {
80+
if (chain.name.toLowerCase() === name.toLowerCase()) {
81+
selectedChain.value = chain;
82+
}
83+
}
84+
}
85+
7186
function search() {
7287
router.push({
73-
params: { walletAddress: walletAddress.value }
88+
params: { walletAddress: walletAddress.value },
89+
query: { network: selectedChain.value.name.toLowerCase() }
7490
});
7591
7692
updateAvatarInfo();

0 commit comments

Comments
 (0)
Please sign in to comment.