mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(crypto address setting): default description didn't appear, clicking 'check' with address already set would result in error
This commit is contained in:
@@ -10,8 +10,8 @@ const CryptoAddressSetting = () => {
|
|||||||
const [cryptoState, setCryptoState] = useState({
|
const [cryptoState, setCryptoState] = useState({
|
||||||
cryptoAddress: '',
|
cryptoAddress: '',
|
||||||
checkingCryptoAddress: false,
|
checkingCryptoAddress: false,
|
||||||
showResolvingMessage: false,
|
showResolvingMessage: true,
|
||||||
resolveString: '',
|
resolveString: t('crypto_address_verification'),
|
||||||
resolveClass: '',
|
resolveClass: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -20,8 +20,11 @@ const CryptoAddressSetting = () => {
|
|||||||
const author = { ...account?.author, address: cryptoState.cryptoAddress };
|
const author = { ...account?.author, address: cryptoState.cryptoAddress };
|
||||||
const { resolvedAddress, state, error, chainProvider } = useResolvedAuthorAddress({ author, cache: false });
|
const { resolvedAddress, state, error, chainProvider } = useResolvedAuthorAddress({ author, cache: false });
|
||||||
|
|
||||||
|
const [inputValue, setInputValue] = useState(account?.author?.shortAddress.includes('.') ? account.author.shortAddress : '');
|
||||||
|
|
||||||
const checkCryptoAddress = () => {
|
const checkCryptoAddress = () => {
|
||||||
if (!cryptoState.cryptoAddress || !cryptoState.cryptoAddress.includes('.')) {
|
const addressToCheck = inputValue || cryptoState.cryptoAddress;
|
||||||
|
if (!addressToCheck || !addressToCheck.includes('.')) {
|
||||||
alert(t('enter_crypto_address'));
|
alert(t('enter_crypto_address'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -48,6 +51,7 @@ const CryptoAddressSetting = () => {
|
|||||||
|
|
||||||
setCryptoState((prevState) => ({
|
setCryptoState((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
|
cryptoAddress: addressToCheck,
|
||||||
showResolvingMessage: true,
|
showResolvingMessage: true,
|
||||||
resolveString,
|
resolveString,
|
||||||
resolveClass,
|
resolveClass,
|
||||||
@@ -106,8 +110,11 @@ const CryptoAddressSetting = () => {
|
|||||||
<input
|
<input
|
||||||
type='text'
|
type='text'
|
||||||
placeholder='address.eth/.sol'
|
placeholder='address.eth/.sol'
|
||||||
defaultValue={cryptoState.cryptoAddress || (account?.author?.shortAddress.includes('.') ? account.author.shortAddress : '')}
|
value={inputValue}
|
||||||
onChange={(e) => setCryptoState((prevState) => ({ ...prevState, cryptoAddress: e.target.value }))}
|
onChange={(e) => {
|
||||||
|
setInputValue(e.target.value);
|
||||||
|
setCryptoState((prevState) => ({ ...prevState, cryptoAddress: e.target.value }));
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<button className={styles.saveButton} onClick={saveCryptoAddress}>
|
<button className={styles.saveButton} onClick={saveCryptoAddress}>
|
||||||
{t('save')}
|
{t('save')}
|
||||||
|
|||||||
Reference in New Issue
Block a user