fix(settings): crypto address setting would show error for an already set address

This commit is contained in:
Tom (plebeius.eth)
2024-12-05 23:13:54 +01:00
parent db8c51fa72
commit cc660e9527
2 changed files with 12 additions and 2 deletions
@@ -41,6 +41,10 @@
margin: 0 5px;
}
.saved {
padding-left: 5px;
}
.red {
color: red;
}
@@ -8,7 +8,7 @@ const CryptoAddressSetting = () => {
const account = useAccount();
const [cryptoState, setCryptoState] = useState({
cryptoAddress: '',
cryptoAddress: account?.author?.shortAddress.includes('.') ? account.author.shortAddress : '',
checkingCryptoAddress: false,
showResolvingMessage: true,
resolveString: t('crypto_address_verification'),
@@ -62,6 +62,12 @@ const CryptoAddressSetting = () => {
if (!cryptoState.cryptoAddress || !cryptoState.cryptoAddress.includes('.')) {
alert(t('enter_crypto_address'));
return;
} else if (cryptoState.cryptoAddress === account?.author?.address) {
setSavedCryptoAddress(true);
setTimeout(() => {
setSavedCryptoAddress(false);
}, 2000);
return;
} else if (resolvedAddress && resolvedAddress !== account?.signer?.address) {
alert(t('crypto_address_not_yours'));
return;
@@ -110,7 +116,7 @@ const CryptoAddressSetting = () => {
<input
type='text'
placeholder='address.eth/.sol'
value={inputValue}
value={cryptoState.cryptoAddress}
onChange={(e) => {
setInputValue(e.target.value);
setCryptoState((prevState) => ({ ...prevState, cryptoAddress: e.target.value }));