Hide "Link ethereum address" from profile menu if wallet is disabled

This commit is contained in:
silverpill 2022-09-10 00:08:10 +00:00
parent 17e52b7b85
commit d84ff0256b
2 changed files with 12 additions and 3 deletions

View file

@ -15,6 +15,10 @@ export function ethereumAddressMatch(address1: string, address2: string): boolea
return address1.toLowerCase() === address2.toLowerCase()
}
export function hasEthereumWallet(): boolean {
return Boolean((window as any).ethereum)
}
export function getWeb3Provider(): Web3Provider {
const provider = (window as any).ethereum
return new Web3Provider(provider)

View file

@ -41,12 +41,12 @@
Atom feed
</a>
</li>
<li v-if="isCurrentUser()">
<li v-if="canVerifyEthereumAddress()">
<button
title="Verify ethereum address"
title="Link ethereum address"
@click="hideProfileMenu(); onVerifyEthereumAddress()"
>
Verify ethereum address
Link ethereum address
</button>
</li>
<li v-if="canManageSubscriptions()">
@ -221,6 +221,7 @@ import { useEthereumAddressVerification } from "@/composables/ethereum-address-v
import { BACKEND_URL } from "@/constants"
import { useInstanceInfo } from "@/store/instance"
import { useCurrentUser } from "@/store/user"
import { hasEthereumWallet } from "@/utils/ethereum"
const route = useRoute()
const {
@ -418,6 +419,10 @@ const feedUrl = $computed<string>(() => {
return `${BACKEND_URL}/feeds/${profile.username}`
})
function canVerifyEthereumAddress(): boolean {
return isCurrentUser() && hasEthereumWallet()
}
async function onVerifyEthereumAddress() {
if (!profile || !isCurrentUser()) {
return