@@ -2,7 +2,7 @@ import React, { useEffect, useMemo } from 'react'
22import { RouteComponentProps } from 'react-router-dom'
33import { useTranslation } from 'react-i18next'
44import {
5- DetailsList ,
5+ ShimmeredDetailsList ,
66 TextField ,
77 IColumn ,
88 DetailsListLayoutMode ,
@@ -11,17 +11,21 @@ import {
1111 getTheme ,
1212} from 'office-ui-fabric-react'
1313
14- import { StateWithDispatch } from 'states/stateProvider/reducer'
1514import { contextMenu } from 'services/remote'
15+ import { StateWithDispatch } from 'states/stateProvider/reducer'
1616
1717import { useLocalDescription } from 'utils/hooks'
1818import { MIN_CELL_WIDTH , Routes } from 'utils/const'
1919import { localNumberFormatter , shannonToCKBFormatter } from 'utils/formatters'
2020
2121const Addresses = ( {
22- wallet : { addresses = [ ] } ,
22+ app : {
23+ loadings : { addressList : isLoading } ,
24+ } ,
25+ wallet : { addresses = [ ] , id : walletID } ,
2326 settings : { showAddressBook = false } ,
2427 history,
28+ dispatch,
2529} : React . PropsWithoutRef < StateWithDispatch & RouteComponentProps > ) => {
2630 const [ t ] = useTranslation ( )
2731 useEffect ( ( ) => {
@@ -31,14 +35,17 @@ const Addresses = ({
3135 } , [ showAddressBook , history ] )
3236
3337 const { localDescription, onDescriptionPress, onDescriptionFieldBlur, onDescriptionChange } = useLocalDescription (
38+ 'address' ,
39+ walletID ,
3440 useMemo (
3541 ( ) =>
3642 addresses . map ( ( { address : key = '' , description = '' } ) => ( {
3743 key,
3844 description,
3945 } ) ) ,
4046 [ addresses ]
41- )
47+ ) ,
48+ dispatch
4249 )
4350
4451 const theme = getTheme ( )
@@ -92,15 +99,17 @@ const Addresses = ({
9299 maxWidth : 350 ,
93100 isResizable : true ,
94101 isCollapsible : false ,
95- onRender : ( item ?: State . Address , idx ?: number ) => {
96- return item && undefined !== idx ? (
102+ onRender : ( item ?: State . Address ) => {
103+ return item ? (
97104 < TextField
98105 borderless
99106 title = { item . description }
100- value = { localDescription [ idx ] || '' }
101- onKeyPress = { onDescriptionPress ( idx ) }
102- onBlur = { onDescriptionFieldBlur ( idx ) }
103- onChange = { onDescriptionChange ( idx ) }
107+ value = {
108+ ( localDescription . find ( local => local . key === item . address ) || { description : '' } ) . description || ''
109+ }
110+ onKeyPress = { onDescriptionPress ( item . address ) }
111+ onBlur = { onDescriptionFieldBlur ( item . address ) }
112+ onChange = { onDescriptionChange ( item . address ) }
104113 styles = { ( props : ITextFieldStyleProps ) => {
105114 return {
106115 root : {
@@ -155,28 +164,15 @@ const Addresses = ({
155164 )
156165
157166 return (
158- < DetailsList
167+ < ShimmeredDetailsList
168+ enableShimmer = { isLoading }
159169 checkboxVisibility = { CheckboxVisibility . hidden }
160170 layoutMode = { DetailsListLayoutMode . justified }
161171 columns = { addressColumns . map ( col => ( { ...col , name : t ( col . name ) } ) ) }
162172 items = { addresses }
163173 onItemContextMenu = { item => {
164174 contextMenu ( { type : 'addressList' , id : item . identifier } )
165175 } }
166- styles = { {
167- contentWrapper : {
168- selectors : {
169- '.ms-DetailsRow-cell' : {
170- display : 'flex' ,
171- alignItems : 'center' ,
172- } ,
173- '.text-overflow' : {
174- overflow : 'hidden' ,
175- textOverflow : 'ellipsis' ,
176- } ,
177- } ,
178- } ,
179- } }
180176 />
181177 )
182178}
0 commit comments