diff --git a/packages/app-staking/src/Actions/Account/index.tsx b/packages/app-staking/src/Actions/Account/index.tsx index 3ea7eeec81..7a85fd8041 100644 --- a/packages/app-staking/src/Actions/Account/index.tsx +++ b/packages/app-staking/src/Actions/Account/index.tsx @@ -27,9 +27,10 @@ import Validate from './Validate'; type Props = ApiProps & I18nProps & { accountId: string; + allStashes?: string[]; + balances_all?: DerivedBalances; className?: string; recentlyOffline: RecentlyOfflineMap; - balances_all?: DerivedBalances; staking_info?: DerivedStaking; stashOptions: KeyringSectionOption[]; }; @@ -37,7 +38,6 @@ type Props = ApiProps & I18nProps & { interface State { controllerId: string | null; destination: number; - isActiveStash: boolean; isBondExtraOpen: boolean; isNominateOpen: boolean; isSetControllerAccountOpen: boolean; @@ -66,7 +66,6 @@ class Account extends React.PureComponent { public state: State = { controllerId: null, destination: 0, - isActiveStash: false, isBondExtraOpen: false, isNominateOpen: false, isSetControllerAccountOpen: false, @@ -81,35 +80,35 @@ class Account extends React.PureComponent { stashId: null }; - public static getDerivedStateFromProps ({ accountId, staking_info }: Props): Pick | null { + public static getDerivedStateFromProps ({ allStashes, staking_info }: Props): Pick | null { if (!staking_info) { return null; } const { controllerId, nextSessionId, nominators, rewardDestination, stakers, stakingLedger, stashId, validatorPrefs } = staking_info; const isStashNominating = nominators && nominators.length !== 0; - const isStashValidating = !!validatorPrefs && !validatorPrefs.isEmpty && !isStashNominating; + const _stashId = toIdString(stashId); + const isStashValidating = !!allStashes && !!_stashId && allStashes.includes(_stashId); return { controllerId: toIdString(controllerId), destination: rewardDestination && rewardDestination.toNumber(), - isActiveStash: accountId === toIdString(stashId), isStashNominating, isStashValidating, nominees: nominators && nominators.map(toIdString), sessionId: toIdString(nextSessionId), stakers, stakingLedger, - stashId: toIdString(stashId), + stashId: _stashId, validatorPrefs }; } public render (): React.ReactNode { const { className, t } = this.props; - const { isActiveStash, stashId } = this.state; + const { stashId } = this.state; - if (!isActiveStash || !stashId) { + if (!stashId) { return null; } diff --git a/packages/app-staking/src/Actions/Accounts.tsx b/packages/app-staking/src/Actions/Accounts.tsx index 6adef828d2..1cc890c681 100644 --- a/packages/app-staking/src/Actions/Accounts.tsx +++ b/packages/app-staking/src/Actions/Accounts.tsx @@ -32,7 +32,7 @@ class Accounts extends React.PureComponent { }; public render (): React.ReactNode { - const { className, recentlyOffline, t } = this.props; + const { allStashes, className, recentlyOffline, t } = this.props; const { isNewStakeOpen } = this.state; const stashOptions = this.getStashOptions(); const myStashes = this.getMyStashes(); @@ -61,6 +61,7 @@ class Accounts extends React.PureComponent { {myStashes && myStashes.map((address, index): React.ReactNode => ( address && { private renderComponent (Component: React.ComponentType): () => React.ReactNode { return (): React.ReactNode => { - const { allControllers, recentlyOffline, allStashes, currentValidatorsControllersV1OrStashesV2 } = this.state; + const { allControllers, allStashes, currentValidatorsControllersV1OrStashesV2, recentlyOffline } = this.state; const { allAccounts } = this.props; if (!allAccounts) {