Add derive availability failsafes (global) (#2210)
* Add derive availability failsafes (global) * Check all isApiReady
This commit is contained in:
parent
09781cc1e5
commit
7466d6b239
@ -9,7 +9,7 @@ import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
export default function useCounter (): number {
|
||||
const { api, isApiReady } = useApi();
|
||||
const motions = useCall<DerivedCollectiveProposals>(isApiReady ? api.derive.council.proposals : undefined, []);
|
||||
const motions = useCall<DerivedCollectiveProposals>(isApiReady ? api.derive.council?.proposals : undefined, []);
|
||||
const [counter, setCounter] = useState(0);
|
||||
|
||||
useEffect((): void => {
|
||||
|
||||
@ -7,8 +7,8 @@ import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
export default function useCounter (): number {
|
||||
const { api, isApiReady } = useApi();
|
||||
const proposals = useCall<any[]>(isApiReady ? api.derive.democracy.proposals : undefined, []);
|
||||
const referenda = useCall<any[]>(isApiReady ? api.derive.democracy.referendums : undefined, []);
|
||||
const proposals = useCall<any[]>(isApiReady ? api.derive.democracy?.proposals : undefined, []);
|
||||
const referenda = useCall<any[]>(isApiReady ? api.derive.democracy?.referendums : undefined, []);
|
||||
const [counter, setCounter] = useState(0);
|
||||
|
||||
useEffect((): void => {
|
||||
|
||||
@ -16,7 +16,7 @@ interface OwnMembers {
|
||||
export default function useMembers (): OwnMembers {
|
||||
const { api } = useApi();
|
||||
const { allAccounts } = useAccounts();
|
||||
const members = useCall<DeriveSocietyMember[]>(api.derive.society.members, []);
|
||||
const members = useCall<DeriveSocietyMember[]>(api.derive.society?.members, []);
|
||||
const [ownState, setOwnState] = useState<OwnMembers>({ allMembers: [], isMember: false, ownMembers: [] });
|
||||
|
||||
useEffect((): void => {
|
||||
|
||||
@ -9,7 +9,7 @@ import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
export default function useCounter (): number {
|
||||
const { api, isApiReady } = useApi();
|
||||
const proposals = useCall<Hash[]>(isApiReady ? api.query.technicalCommittee && api.query.technicalCommittee.proposals : undefined, []);
|
||||
const proposals = useCall<Hash[]>(isApiReady ? api.query.technicalCommittee?.proposals : undefined, []);
|
||||
const [counter, setCounter] = useState(0);
|
||||
|
||||
useEffect((): void => {
|
||||
|
||||
@ -9,7 +9,7 @@ import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
export default function useCounter (): number {
|
||||
const { api, isApiReady } = useApi();
|
||||
const proposals = useCall<DerivedTreasuryProposals>(isApiReady ? api.derive.treasury.proposals : undefined, []);
|
||||
const proposals = useCall<DerivedTreasuryProposals>(isApiReady ? api.derive.treasury?.proposals : undefined, []);
|
||||
const [counter, setCounter] = useState(0);
|
||||
|
||||
useEffect((): void => {
|
||||
|
||||
@ -27,10 +27,10 @@ interface SidebarState {
|
||||
|
||||
function WarmUp (): React.ReactElement {
|
||||
const { api, isApiReady } = useApi();
|
||||
const fees = useCall<any>(isApiReady ? api.derive.balances.fees : undefined, []);
|
||||
const indexes = useCall<any>(isApiReady ? api.derive.accounts.indexes : undefined, []);
|
||||
const fees = useCall<any>(isApiReady ? api.derive.balances?.fees : undefined, []);
|
||||
const indexes = useCall<any>(isApiReady ? api.derive.accounts?.indexes : undefined, []);
|
||||
const registrars = useCall<any>(isApiReady ? api.query.identity?.registrars : undefined, []);
|
||||
const staking = useCall<any>(isApiReady ? api.derive.staking.overview : undefined, []);
|
||||
const staking = useCall<any>(isApiReady ? api.derive.staking?.overview : undefined, []);
|
||||
const [hasValues, setHasValues] = useState(false);
|
||||
|
||||
useEffect((): void => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user