@@ -2,7 +2,7 @@ import React, { useEffect, useMemo } from 'react'
2
2
import { RouteComponentProps } from 'react-router-dom'
3
3
import { useTranslation } from 'react-i18next'
4
4
import {
5
- DetailsList ,
5
+ ShimmeredDetailsList ,
6
6
TextField ,
7
7
IColumn ,
8
8
DetailsListLayoutMode ,
@@ -11,17 +11,21 @@ import {
11
11
getTheme ,
12
12
} from 'office-ui-fabric-react'
13
13
14
- import { StateWithDispatch } from 'states/stateProvider/reducer'
15
14
import { contextMenu } from 'services/remote'
15
+ import { StateWithDispatch } from 'states/stateProvider/reducer'
16
16
17
17
import { useLocalDescription } from 'utils/hooks'
18
18
import { MIN_CELL_WIDTH , Routes } from 'utils/const'
19
19
import { localNumberFormatter , shannonToCKBFormatter } from 'utils/formatters'
20
20
21
21
const Addresses = ( {
22
- wallet : { addresses = [ ] } ,
22
+ app : {
23
+ loadings : { addressList : isLoading } ,
24
+ } ,
25
+ wallet : { addresses = [ ] , id : walletID } ,
23
26
settings : { showAddressBook = false } ,
24
27
history,
28
+ dispatch,
25
29
} : React . PropsWithoutRef < StateWithDispatch & RouteComponentProps > ) => {
26
30
const [ t ] = useTranslation ( )
27
31
useEffect ( ( ) => {
@@ -31,14 +35,17 @@ const Addresses = ({
31
35
} , [ showAddressBook , history ] )
32
36
33
37
const { localDescription, onDescriptionPress, onDescriptionFieldBlur, onDescriptionChange } = useLocalDescription (
38
+ 'address' ,
39
+ walletID ,
34
40
useMemo (
35
41
( ) =>
36
42
addresses . map ( ( { address : key = '' , description = '' } ) => ( {
37
43
key,
38
44
description,
39
45
} ) ) ,
40
46
[ addresses ]
41
- )
47
+ ) ,
48
+ dispatch
42
49
)
43
50
44
51
const theme = getTheme ( )
@@ -92,15 +99,17 @@ const Addresses = ({
92
99
maxWidth : 350 ,
93
100
isResizable : true ,
94
101
isCollapsible : false ,
95
- onRender : ( item ?: State . Address , idx ?: number ) => {
96
- return item && undefined !== idx ? (
102
+ onRender : ( item ?: State . Address ) => {
103
+ return item ? (
97
104
< TextField
98
105
borderless
99
106
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 ) }
104
113
styles = { ( props : ITextFieldStyleProps ) => {
105
114
return {
106
115
root : {
@@ -155,28 +164,15 @@ const Addresses = ({
155
164
)
156
165
157
166
return (
158
- < DetailsList
167
+ < ShimmeredDetailsList
168
+ enableShimmer = { isLoading }
159
169
checkboxVisibility = { CheckboxVisibility . hidden }
160
170
layoutMode = { DetailsListLayoutMode . justified }
161
171
columns = { addressColumns . map ( col => ( { ...col , name : t ( col . name ) } ) ) }
162
172
items = { addresses }
163
173
onItemContextMenu = { item => {
164
174
contextMenu ( { type : 'addressList' , id : item . identifier } )
165
175
} }
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
- } }
180
176
/>
181
177
)
182
178
}
0 commit comments