Fix Tech comm proposal display (Option) (#1995)

* Fix Tech comm proposal display (Option)

* Linting
This commit is contained in:
Jaco Greeff 2019-12-03 20:29:01 +01:00 committed by GitHub
parent e1d59233e0
commit aeb0ea3f0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -12,7 +12,7 @@ import { Call } from '@polkadot/react-components';
import translate from '../translate';
interface Props extends I18nProps {
proposal?: Proposal;
proposal?: Proposal | null;
proposalHash: Hash | string;
}

View File

@ -6,10 +6,10 @@ import { Proposal as ProposalType, Votes } from '@polkadot/types/interfaces';
import { I18nProps } from '@polkadot/react-components/types';
import React from 'react';
import { useApi, trackStream } from '@polkadot/react-hooks';
import { Option } from '@polkadot/types';
import { AddressMini } from '@polkadot/react-components';
import { useApi, trackStream } from '@polkadot/react-hooks';
import ProposalCell from '@polkadot/app-democracy/Overview/ProposalCell';
import { Option } from '@polkadot/types';
import { formatNumber } from '@polkadot/util';
import translate from '../translate';
@ -21,13 +21,14 @@ interface Props extends I18nProps {
function Proposal ({ className, hash, t }: Props): React.ReactElement<Props> | null {
const { api } = useApi();
const proposal = trackStream<ProposalType>(api.query.technicalCommittee.proposalOf, [hash]);
const _proposal = trackStream<Option<ProposalType>>(api.query.technicalCommittee.proposalOf, [hash]);
const votes = trackStream<Option<Votes>>(api.query.technicalCommittee.voting, [hash]);
if (!proposal || !votes?.isSome) {
if (!votes?.isSome) {
return null;
}
const proposal = _proposal?.unwrapOr(null);
const { ayes, index, nays, threshold } = votes.unwrap();
return (