diff --git a/packages/app-staking/src/Overview/Address.tsx b/packages/app-staking/src/Overview/Address.tsx index c3ab71ebe2..d5f7985040 100644 --- a/packages/app-staking/src/Overview/Address.tsx +++ b/packages/app-staking/src/Overview/Address.tsx @@ -26,7 +26,7 @@ interface Props extends I18nProps { defaultName: string; filter: ValidatorFilter; lastAuthor?: string; - points?: [Points, Points]; + points?: Points; recentlyOnline?: DerivedHeartbeats; stakingInfo?: DerivedStaking; withNominations?: boolean; @@ -52,6 +52,7 @@ const WITH_VALIDATOR_PREFS = { validatorPayment: true }; function Address ({ authorsMap, className, defaultName, filter, lastAuthor, points, recentlyOnline, stakingInfo, t, withNominations }: Props): React.ReactElement | null { const { isSubstrateV2 } = useContext(ApiContext); + const [extraInfo, setExtraInfo] = useState<[React.ReactNode, React.ReactNode][] | undefined>(); const [isNominatorMe, seIsNominatorMe] = useState(false); const [{ hasOfflineWarnings, onlineStatus }, setOnlineStatus] = useState({ hasOfflineWarnings: false, @@ -64,7 +65,16 @@ function Address ({ authorsMap, className, defaultName, filter, lastAuthor, poin stashActive: null, stashTotal: null }); - const [isAuthor, setIsAuthor] = useState(false); + + useEffect((): void => { + if (points) { + const formatted = formatNumber(points); + + if (!extraInfo || extraInfo[0][1] !== formatted) { + setExtraInfo([[t('era points'), formatted]]); + } + } + }, [extraInfo, points]); useEffect((): void => { if (stakingInfo) { @@ -110,10 +120,6 @@ function Address ({ authorsMap, className, defaultName, filter, lastAuthor, poin } }, [recentlyOnline, stakingInfo]); - useEffect((): void => { - setIsAuthor(lastAuthor === stashId); - }, [lastAuthor, stashId]); - if (!stashId || (filter === 'hasNominators' && !hasNominators) || (filter === 'noNominators' && hasNominators) || (filter === 'hasWarnings' && !hasOfflineWarnings) || @@ -123,8 +129,7 @@ function Address ({ authorsMap, className, defaultName, filter, lastAuthor, poin } const lastBlockNumber = authorsMap[stashId]; - - points && console.error(points); + const isAuthor = lastAuthor === stashId; return ( )} - isDisabled={!!points && points[0].isEmpty} + isDisabled={!!points && points.isEmpty} key={stashId} value={stashId} withBalance={balanceOpts} diff --git a/packages/app-staking/src/Overview/CurrentList.tsx b/packages/app-staking/src/Overview/CurrentList.tsx index 6bc53eaff9..96f633b8af 100644 --- a/packages/app-staking/src/Overview/CurrentList.tsx +++ b/packages/app-staking/src/Overview/CurrentList.tsx @@ -22,28 +22,29 @@ interface Props extends I18nProps { recentlyOnline?: DerivedHeartbeats; } -function CurrentList ({ authorsMap, currentValidators, eraPoints, lastAuthor, next, recentlyOnline, t }: Props): React.ReactElement { - const [filter, setFilter] = useState('all'); +function renderColumn (addresses: string[], defaultName: string, withExpanded: boolean, filter: string, { authorsMap, eraPoints, lastAuthor, recentlyOnline }: Props): React.ReactNode { + return addresses.map((address, index): React.ReactNode => ( +
+ )); +} - const _renderColumn = (addresses: string[], defaultName: string, withExpanded: boolean): React.ReactNode => { - return addresses.map((address, index): React.ReactNode => ( -
- )); - }; +function CurrentList (props: Props): React.ReactElement { + const [filter, setFilter] = useState('all'); + const { currentValidators, next, t } = props; return (
@@ -67,13 +68,13 @@ function CurrentList ({ authorsMap, currentValidators, eraPoints, lastAuthor, ne emptyText={t('No addresses found')} headerText={t('validators')} > - {_renderColumn(currentValidators, t('validator'), true)} + {renderColumn(currentValidators, t('validator'), true, filter, props)} - {_renderColumn(next, t('intention'), false)} + {renderColumn(next, t('intention'), false, filter, props)}