Pull members from collective itself (isMember checks) (#2704)

* Pull members from collective itself (isMember checks)

* trigger stuck CI (hopefully)
This commit is contained in:
Jaco Greeff 2020-05-07 19:53:13 +02:00 committed by GitHub
parent 6b8ad93432
commit f7c61f4698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 15 deletions

View File

@ -1 +1 @@
7
8

View File

@ -2,7 +2,6 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { DeriveElectionsInfo } from '@polkadot/api-derive/types';
import { AccountId } from '@polkadot/types/interfaces';
import { useEffect, useState } from 'react';
@ -17,19 +16,9 @@ export default function useMembers (collective: 'council' | 'technicalCommittee'
const { api } = useApi();
const { allAccounts, hasAccounts } = useAccounts();
const [state, setState] = useState<Result>({ isMember: false, members: [] });
const retrieved = (
collective === 'council'
// eslint-disable-next-line react-hooks/rules-of-hooks
? useCall<string[]>(hasAccounts && api.derive.elections.info, [], {
transform: ({ members }: DeriveElectionsInfo): string[] =>
members.map(([accountId]) => accountId.toString())
})
// eslint-disable-next-line react-hooks/rules-of-hooks
: useCall<string[]>(hasAccounts && api.query.technicalCommittee?.members, [], {
transform: (accounts: AccountId[]): string[] =>
accounts.map((accountId) => accountId.toString())
})
);
const retrieved = useCall<string[]>(hasAccounts && api.query[collective]?.members, [], {
transform: (accounts: AccountId[]) => accounts.map((accountId) => accountId.toString())
});
useEffect((): void => {
retrieved && setState({