Skip to content

Commit 7ef67cb

Browse files
committed
frontend/receive: more accurate name dialog
The dialog shows address types not an address.
1 parent d007cef commit 7ef67cb

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

frontends/web/src/routes/account/receive/receive.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type TProps = {
3737
code: accountApi.AccountCode;
3838
};
3939

40-
type AddressDialog = { addressType: number } | undefined;
40+
type AddressTypeDialog = { addressType: number } | undefined;
4141

4242
// For BTC/LTC: all possible address types we want to offer to the user, ordered by priority (first one is default).
4343
// Types that are not available in the addresses delivered by the backend should be ignored.
@@ -63,7 +63,7 @@ export const Receive = ({
6363
const [activeIndex, setActiveIndex] = useState<number>(0);
6464
// index into `availableScriptTypes`, or 0 if none are available.
6565
const [addressType, setAddressType] = useState<number>(0);
66-
const [addressDialog, setAddressDialog] = useState<AddressDialog>();
66+
const [addressTypeDialog, setAddressTypeDialog] = useState<AddressTypeDialog>();
6767
const [currentAddresses, setCurrentAddresses] = useState<accountApi.IReceiveAddress[]>();
6868
const [currentAddressIndex, setCurrentAddressIndex] = useState<number>(0);
6969

@@ -76,9 +76,9 @@ export const Receive = ({
7676
const availableScriptTypes = useRef<accountApi.ScriptType[]>();
7777

7878
const hasManyScriptTypes = availableScriptTypes.current && availableScriptTypes.current.length > 1;
79-
const scriptTypeDialogOpened = !!(addressDialog && (hasManyScriptTypes || insured));
79+
const addressTypeDialogOpened = !!(addressTypeDialog && (hasManyScriptTypes || insured));
8080

81-
useEsc(() => !scriptTypeDialogOpened && !verifying && route(`/account/${code}`));
81+
useEsc(() => !addressTypeDialogOpened && !verifying && route(`/account/${code}`));
8282

8383
useEffect(() => {
8484
if (receiveAddresses) {
@@ -99,11 +99,11 @@ export const Receive = ({
9999
}, [addressType, availableScriptTypes, receiveAddresses]);
100100

101101
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
102-
if (addressDialog) {
102+
if (addressTypeDialog) {
103103
e.preventDefault();
104104
setActiveIndex(0);
105-
setAddressType(addressDialog.addressType);
106-
setAddressDialog(undefined);
105+
setAddressType(addressTypeDialog.addressType);
106+
setAddressTypeDialog(undefined);
107107
}
108108
};
109109

@@ -206,25 +206,25 @@ export const Receive = ({
206206
{ (hasManyScriptTypes || insured) && (
207207
<button
208208
className={style.changeType}
209-
onClick={() => setAddressDialog(!addressDialog ? { addressType } : undefined)}>
209+
onClick={() => setAddressTypeDialog(!addressTypeDialog ? { addressType } : undefined)}>
210210
{t('receive.changeScriptType')}
211211
</button>
212212
)}
213213
<form onSubmit={handleSubmit}>
214-
<Dialog open={scriptTypeDialogOpened} onClose={() => setAddressDialog(undefined)} medium title={t('receive.changeScriptType')} >
214+
<Dialog open={addressTypeDialogOpened} onClose={() => setAddressTypeDialog(undefined)} medium title={t('receive.changeScriptType')} >
215215
{availableScriptTypes.current && availableScriptTypes.current.map((scriptType, i) => (
216216
<div key={scriptType}>
217-
{addressDialog && (
217+
{addressTypeDialog && (
218218
<>
219219
<Radio
220-
checked={addressDialog.addressType === i}
220+
checked={addressTypeDialog.addressType === i}
221221
id={scriptType}
222222
name="scriptType"
223-
onChange={() => setAddressDialog({ addressType: i })}
223+
onChange={() => setAddressTypeDialog({ addressType: i })}
224224
title={getScriptName(scriptType)}>
225225
{t(`receive.scriptType.${scriptType}`)}
226226
</Radio>
227-
{scriptType === 'p2tr' && addressDialog.addressType === i && (
227+
{scriptType === 'p2tr' && addressTypeDialog.addressType === i && (
228228
<Message type="warning">
229229
{t('receive.taprootWarning')}
230230
</Message>

0 commit comments

Comments
 (0)