Ensure siDefault is always used on InputNumber (#5810)

This commit is contained in:
Jaco 2021-07-12 07:33:50 +03:00 committed by GitHub
parent 1c4296d6f9
commit c3da616b55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -3,7 +3,6 @@
import type { ApiPromise } from '@polkadot/api';
import type { DeriveSocietyCandidate } from '@polkadot/api-derive/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { Voters } from './types';
import { useEffect, useState } from 'react';
@ -13,16 +12,13 @@ import { useApi, useCall, useEventTrigger } from '@polkadot/react-hooks';
const EMPTY_VOTERS: Voters = {};
async function getVoters (api: ApiPromise, candidates: DeriveSocietyCandidate[]): Promise<Voters> {
const accountIds: AccountId[] = [];
const skeptics: string[] = [];
const voters: string[] = [];
candidates.forEach(({ accountId }): void => {
accountIds.push(accountId);
});
const entries = accountIds.length
? await Promise.all(accountIds.map((a) => api.query.society.votes.entries(a)))
const entries = candidates.length
? await Promise.all(candidates.map(({ accountId }) =>
api.query.society.votes.entries(accountId)
))
: [];
entries.forEach((list): void => {

View File

@ -292,10 +292,18 @@ function InputNumber ({ autoFocus, bitLength = DEFAULT_BITLENGTH, children, clas
>
{!!si && (
<Dropdown
defaultValue={si.value}
defaultValue={
isDisabled && siDefault
? siDefault.value
: si.value
}
dropdownClassName='ui--SiDropdown'
isButton
onChange={_onSelectSiUnit}
onChange={
isDisabled
? undefined
: _onSelectSiUnit
}
options={siOptions}
/>
)}