@@ -20,7 +20,7 @@ import { localNumberFormatter, shannonToCKBFormatter } from 'utils/formatters'
2020
2121const Addresses = ( {
2222 app : {
23- loadings : { addressList : isLoading } ,
23+ loadings : { addressList : isLoading , updateDescription : isUpdatingDescription } ,
2424 } ,
2525 wallet : { addresses = [ ] , id : walletID } ,
2626 settings : { showAddressBook = false } ,
@@ -34,19 +34,13 @@ const Addresses = ({
3434 }
3535 } , [ showAddressBook , history ] )
3636
37- const { localDescription, onDescriptionPress, onDescriptionFieldBlur, onDescriptionChange } = useLocalDescription (
38- 'address' ,
39- walletID ,
40- useMemo (
41- ( ) =>
42- addresses . map ( ( { address : key = '' , description = '' } ) => ( {
43- key,
44- description,
45- } ) ) ,
46- [ addresses ]
47- ) ,
48- dispatch
49- )
37+ const {
38+ localDescription,
39+ onDescriptionPress,
40+ onDescriptionFieldBlur,
41+ onDescriptionChange,
42+ onDescriptionFocus,
43+ } = useLocalDescription ( 'address' , walletID , dispatch )
5044
5145 const theme = getTheme ( )
5246 const { semanticColors } = theme
@@ -104,12 +98,15 @@ const Addresses = ({
10498 < TextField
10599 borderless
106100 title = { item . description }
107- value = {
108- ( localDescription . find ( local => local . key === item . address ) || { description : '' } ) . description || ''
109- }
110- onKeyPress = { onDescriptionPress ( item . address ) }
111- onBlur = { onDescriptionFieldBlur ( item . address ) }
101+ value = { localDescription . key === item . address ? localDescription . description : item . description || '' }
102+ onBlur = { onDescriptionFieldBlur ( item . address , item . description ) }
103+ onFocus = { onDescriptionFocus }
104+ onKeyPress = { onDescriptionPress ( item . address , item . description ) }
112105 onChange = { onDescriptionChange ( item . address ) }
106+ disabled = { localDescription . key === item . address && isUpdatingDescription }
107+ iconProps = { {
108+ iconName : localDescription . key === item . address && isUpdatingDescription ? 'Updating' : '' ,
109+ } }
113110 styles = { ( props : ITextFieldStyleProps ) => {
114111 return {
115112 root : {
@@ -160,7 +157,16 @@ const Addresses = ({
160157 } ,
161158 } ,
162159 ] ,
163- [ onDescriptionChange , localDescription , onDescriptionFieldBlur , onDescriptionPress , t , semanticColors ]
160+ [
161+ onDescriptionChange ,
162+ localDescription ,
163+ onDescriptionFieldBlur ,
164+ onDescriptionPress ,
165+ onDescriptionFocus ,
166+ isUpdatingDescription ,
167+ t ,
168+ semanticColors ,
169+ ]
164170 )
165171
166172 return (
0 commit comments