diff --git a/packages/app-staking/src/StakeList/Account.tsx b/packages/app-staking/src/StakeList/Account.tsx index 57fb9abf20..9e907dda7d 100644 --- a/packages/app-staking/src/StakeList/Account.tsx +++ b/packages/app-staking/src/StakeList/Account.tsx @@ -33,22 +33,22 @@ type Props = ApiProps & I18nProps & { type State = { isNominateOpen: boolean, - isNominating: boolean, - isPrefsOpen: boolean + isPrefsOpen: boolean, + nominee: AccountId | null }; class Account extends React.PureComponent { state: State = { isNominateOpen: false, - isNominating: false, - isPrefsOpen: false + isPrefsOpen: false, + nominee: null }; - static getDerivedStateFromProps ({ staking_nominating }: Props) { - const isNominating = !!staking_nominating && !staking_nominating.isEmpty; - + static getDerivedStateFromProps ({ staking_nominating }: Props): Partial { return { - isNominating + nominee: staking_nominating + ? staking_nominating.unwrapOr(null) + : null }; } @@ -76,19 +76,17 @@ class Account extends React.PureComponent { } private renderNominee () { - const { staking_nominating, balanceArray } = this.props; - const { isNominating } = this.state; + const { balanceArray } = this.props; + const { nominee } = this.state; - if (!isNominating || !staking_nominating || staking_nominating.isNone) { + if (!nominee) { return null; } - const nominating = staking_nominating.unwrap(); - return ( ); @@ -153,10 +151,10 @@ class Account extends React.PureComponent { } private renderButtons () { - const { accountId, intentions, staking_nominating, t } = this.props; - const { isNominating } = this.state; + const { accountId, intentions, t } = this.props; + const { nominee } = this.state; const isIntending = intentions.includes(accountId); - const canStake = !isIntending && !isNominating; + const canStake = !isIntending && !nominee; if (canStake) { return ( @@ -176,12 +174,12 @@ class Account extends React.PureComponent { ); } - if (isNominating) { + if (nominee) { return ( diff --git a/packages/app-staking/src/StakeList/UnnominateButton.tsx b/packages/app-staking/src/StakeList/UnnominateButton.tsx index a364d0d23d..f429a28425 100644 --- a/packages/app-staking/src/StakeList/UnnominateButton.tsx +++ b/packages/app-staking/src/StakeList/UnnominateButton.tsx @@ -7,13 +7,14 @@ import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Button } from '@polkadot/ui-app'; import { withCall, withMulti } from '@polkadot/ui-api'; +import { AccountId, Vector } from '@polkadot/types'; import translate from '../translate'; type Props = I18nProps & { accountId: string, - nominating: string, - staking_nominatorsFor: Array, + nominating: AccountId, + staking_nominatorsFor: Vector, onClick: (index: number) => void }; @@ -41,9 +42,7 @@ class UnnominateButton extends React.Component { onClick( staking_nominatorsFor - .map((accountId) => - accountId.toString() - ) + .map((accountId) => accountId.toString()) .indexOf(accountId)); } } diff --git a/packages/ui-api/src/with/call.tsx b/packages/ui-api/src/with/call.tsx index 4b067131d9..d9d7d6478a 100644 --- a/packages/ui-api/src/with/call.tsx +++ b/packages/ui-api/src/with/call.tsx @@ -5,7 +5,6 @@ import { ApiProps, CallState, Subtract } from '../types'; import { Options } from './types'; -import memoize from 'memoizee'; import React from 'react'; import { assert, isNull, isUndefined } from '@polkadot/util'; @@ -159,7 +158,7 @@ export default function withCall

(endpoint: string, { at, at await this.unsubscribe(); if (isSubscription) { - this.destroy = await memoize(apiMethod)(...params, (value?: any) => + this.destroy = await apiMethod(...params, (value?: any) => this.triggerUpdate(this.props, value) ); } else {