From 1874bee019494bf88b9ba6d9377a085ae4ecb62f Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 8 Nov 2019 10:58:41 +0100 Subject: [PATCH] Only highlight stashes (not controllers) (#1854) --- .../react-components/src/IdentityIcon.tsx | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/packages/react-components/src/IdentityIcon.tsx b/packages/react-components/src/IdentityIcon.tsx index 469ad2f8ab..8e1dfaa91b 100644 --- a/packages/react-components/src/IdentityIcon.tsx +++ b/packages/react-components/src/IdentityIcon.tsx @@ -9,7 +9,6 @@ import { IdentityProps } from '@polkadot/react-identicon/types'; import { I18nProps } from './types'; import React, { useContext, useEffect, useState } from 'react'; -import { Option } from '@polkadot/types'; import { ApiContext, withCalls, withMulti } from '@polkadot/react-api'; import BaseIdentityIcon from '@polkadot/react-identicon'; import uiSettings from '@polkadot/ui-settings'; @@ -18,8 +17,6 @@ import StatusContext from './Status/Context'; import translate from './translate'; interface Props extends IdentityProps, I18nProps { - staking_bonded?: string | null; - system_name?: string; validators?: AccountId[]; } @@ -33,31 +30,20 @@ const NODES: Record = { 'substrate-node': 'substrate' }; -// toString() => null -const NULL_TOSTRING = { - toString: (): null => null -}; - export function getIdentityTheme (systemName: string): 'empty' { return ((uiSettings.icon === 'default' && NODES[systemName]) || uiSettings.icon) as 'empty'; } -function IdentityIcon ({ className, onCopy, prefix, size, staking_bonded, style, t, theme, validators, value }: Props): React.ReactElement { +function IdentityIcon ({ className, onCopy, prefix, size, style, t, theme, validators, value }: Props): React.ReactElement { const { systemName } = useContext(ApiContext); const { queueAction } = useContext(StatusContext); const [isValidator, setIsValidator] = useState(false); const thisTheme = theme || getIdentityTheme(systemName); useEffect((): void => { - const address = value - ? value.toString() - : null; - setIsValidator( validators - ? validators.some((validator): boolean => - [address, staking_bonded].includes(validator.toString()) - ) + ? validators.some((validator): boolean => validator.eq(value)) : false ); }, [validators, value]); @@ -93,11 +79,6 @@ export default withMulti( ['derive.staking.validators', { propName: 'validators', transform: ({ validators }): DeriveStakingValidators => validators - }], - ['query.staking.bonded', { - paramName: 'value', - transform: (bonded: Option): string | null => - bonded.unwrapOr(NULL_TOSTRING).toString() }] ) );