11/// <reference types="react/canary" />
22import { Trans } from '@lingui/react/macro'
3- import { EthereumBlockie } from '@masknet/shared'
3+ import { EmptyStatus , EthereumBlockie } from '@masknet/shared'
44import type { NetworkPluginID } from '@masknet/shared-base'
55import { makeStyles , ShadowRootTooltip , TextOverflowTooltip } from '@masknet/theme'
66import { useChainContext } from '@masknet/web3-hooks-base'
77import { formatCount , formatPercentage , isSameAddress } from '@masknet/web3-shared-base'
8- import { formatEthereumAddress } from '@masknet/web3-shared-evm'
98import { Badge , Box , Link , List , ListItem , Typography } from '@mui/material'
109import { unstable_useCacheRefresh , useContext } from 'react'
1110import { SnapshotContext } from '../context.js'
@@ -14,6 +13,7 @@ import { useVotes } from './hooks/useVotes.js'
1413import { LoadingCard } from './LoadingCard.js'
1514import { LoadingFailCard } from './LoadingFailCard.js'
1615import { SnapshotCard } from './SnapshotCard.js'
16+ import { formatLongHex } from './helpers.js'
1717
1818const useStyles = makeStyles ( ) ( ( theme ) => {
1919 return {
@@ -101,73 +101,80 @@ function Content() {
101101 < Trans > Votes</ Trans >
102102 </ Badge >
103103 } >
104- < List className = { classes . list } >
105- { votes . map ( function voteItemIter ( v ) {
106- const isAverageWeight = v . choices ?. every ( ( c ) => c . weight === 1 )
107- const fullChoiceText =
108- v . totalWeight && v . choices ?
109- v . choices
110- . flatMap ( ( choice , index ) => [
111- index === 0 ? '' : ', ' ,
112- ! isAverageWeight ? formatPercentage ( choice . weight / v . totalWeight ! ) + ' ' : '' ,
113- choice . name ,
114- ] )
115- . join ( '' )
116- : null
117- const link = `https://snapshot.box/#/${ identifier . space } /profile/${ v . address } `
118- return (
119- < ListItem className = { classes . listItem } key = { v . address } >
120- < Link
121- className = { cx ( classes . link , classes . ellipsisText ) }
122- target = "_blank"
123- rel = "noopener"
124- href = { link } >
125- < Box className = { classes . avatarWrapper } >
126- < EthereumBlockie address = { v . address } />
127- </ Box >
128- < Typography color = { theme . palette . maskColor . dark } >
129- { isSameAddress ( v . address , account ) ?
130- < Trans > You</ Trans >
131- : formatEthereumAddress ( v . address , 4 ) }
132- </ Typography >
133- </ Link >
134- { v . choice ?
135- < Typography className = { classes . choice } > { v . choice } </ Typography >
136- : v . choices ?
137- < ShadowRootTooltip
104+ { votes . length ?
105+ < List className = { classes . list } >
106+ { votes . map ( function voteItemIter ( v ) {
107+ const isAverageWeight = v . choices ?. every ( ( c ) => c . weight === 1 )
108+ const fullChoiceText =
109+ v . totalWeight && v . choices ?
110+ v . choices
111+ . flatMap ( ( choice , index ) => [
112+ index === 0 ? '' : ', ' ,
113+ ! isAverageWeight ? formatPercentage ( choice . weight / v . totalWeight ! ) + ' ' : '' ,
114+ choice . name ,
115+ ] )
116+ . join ( '' )
117+ : null
118+ const link = `https://snapshot.box/#/${ identifier . space } /profile/${ v . address } `
119+ return (
120+ < ListItem className = { classes . listItem } key = { v . address } >
121+ < Link
122+ className = { cx ( classes . link , classes . ellipsisText ) }
123+ target = "_blank"
124+ rel = "noopener"
125+ href = { link } >
126+ < Box className = { classes . avatarWrapper } >
127+ < EthereumBlockie address = { v . address } />
128+ </ Box >
129+ < Typography color = { theme . palette . maskColor . dark } >
130+ { isSameAddress ( v . address , account ) ?
131+ < Trans > You</ Trans >
132+ : formatLongHex ( v . address ) }
133+ </ Typography >
134+ </ Link >
135+ { v . choice ?
136+ < Typography className = { classes . choice } > { v . choice } </ Typography >
137+ : v . choices ?
138+ < ShadowRootTooltip
139+ PopperProps = { {
140+ disablePortal : false ,
141+ } }
142+ title = {
143+ < Typography className = { classes . shadowRootTooltip } >
144+ { fullChoiceText }
145+ </ Typography >
146+ }
147+ placement = "top"
148+ classes = { { tooltip : classes . tooltip , arrow : classes . arrow } }
149+ arrow >
150+ < Typography className = { classes . choice } > { fullChoiceText } </ Typography >
151+ </ ShadowRootTooltip >
152+ : null }
153+ < TextOverflowTooltip
154+ as = { ShadowRootTooltip }
138155 PopperProps = { {
139- disablePortal : false ,
156+ disablePortal : true ,
140157 } }
158+ classes = { { tooltip : classes . tooltip , arrow : classes . arrow } }
141159 title = {
142- < Typography className = { classes . shadowRootTooltip } > { fullChoiceText } </ Typography >
160+ < Typography className = { classes . shadowRootTooltip } >
161+ { formatCount ( v . balance , 2 , true ) + ' ' + v . strategySymbol . toUpperCase ( ) }
162+ </ Typography >
143163 }
144164 placement = "top"
145- classes = { { tooltip : classes . tooltip , arrow : classes . arrow } }
146165 arrow >
147- < Typography className = { classes . choice } > { fullChoiceText } </ Typography >
148- </ ShadowRootTooltip >
149- : null }
150- < TextOverflowTooltip
151- as = { ShadowRootTooltip }
152- PopperProps = { {
153- disablePortal : true ,
154- } }
155- classes = { { tooltip : classes . tooltip , arrow : classes . arrow } }
156- title = {
157- < Typography className = { classes . shadowRootTooltip } >
166+ < Typography className = { classes . power } >
158167 { formatCount ( v . balance , 2 , true ) + ' ' + v . strategySymbol . toUpperCase ( ) }
159168 </ Typography >
160- }
161- placement = "top"
162- arrow >
163- < Typography className = { classes . power } >
164- { formatCount ( v . balance , 2 , true ) + ' ' + v . strategySymbol . toUpperCase ( ) }
165- </ Typography >
166- </ TextOverflowTooltip >
167- </ ListItem >
168- )
169- } ) }
170- </ List >
169+ </ TextOverflowTooltip >
170+ </ ListItem >
171+ )
172+ } ) }
173+ </ List >
174+ : < EmptyStatus >
175+ < Trans > No votes</ Trans >
176+ </ EmptyStatus >
177+ }
171178 </ SnapshotCard >
172179 )
173180}
0 commit comments