From 7d1e037fdb311a3200a84be31b2b258252395d2a Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 25 Jan 2023 13:19:59 +0200 Subject: [PATCH] Add missing inline preimage conditions (#8882) --- packages/page-referenda/src/Referenda/RefOngoing.tsx | 10 ++++++---- packages/react-hooks/src/usePreimage.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/page-referenda/src/Referenda/RefOngoing.tsx b/packages/page-referenda/src/Referenda/RefOngoing.tsx index 13deba6a3b..02668342f7 100644 --- a/packages/page-referenda/src/Referenda/RefOngoing.tsx +++ b/packages/page-referenda/src/Referenda/RefOngoing.tsx @@ -3,7 +3,7 @@ import type { ApiPromise } from '@polkadot/api'; import type { Hash } from '@polkadot/types/interfaces'; -import type { PalletConvictionVotingTally, PalletRankedCollectiveTally, PalletReferendaDeposit, PalletReferendaTrackInfo } from '@polkadot/types/lookup'; +import type { PalletConvictionVotingTally, PalletRankedCollectiveTally, PalletReferendaDeposit, PalletReferendaReferendumStatusConvictionVotingTally, PalletReferendaReferendumStatusRankedCollectiveTally, PalletReferendaTrackInfo } from '@polkadot/types/lookup'; import type { BN } from '@polkadot/util'; import type { HexString } from '@polkadot/util/types'; import type { Referendum, ReferendumProps as Props } from '../types'; @@ -29,6 +29,7 @@ interface Expanded { decideEnd: BN | null; confirmEnd: BN | null; }; + ongoing: PalletReferendaReferendumStatusConvictionVotingTally | PalletReferendaReferendumStatusRankedCollectiveTally; proposalHash?: HexString; submissionDeposit: PalletReferendaDeposit | null; tally: PalletConvictionVotingTally | PalletRankedCollectiveTally; @@ -63,6 +64,7 @@ function expandOngoing (api: ApiPromise, info: Referendum['info'], track?: Palle return { decisionDeposit: unwrapDeposit(ongoing.decisionDeposit), + ongoing, periods: { confirmEnd, decideEnd, @@ -80,12 +82,12 @@ function Ongoing ({ isMember, members, palletReferenda, palletVote, ranks, track const { t } = useTranslation(); const { api } = useApi(); - const { decisionDeposit, periods: { confirmEnd, decideEnd, periodEnd }, proposalHash, submissionDeposit, tally, tallyTotal } = useMemo( + const { decisionDeposit, ongoing, periods: { confirmEnd, decideEnd, periodEnd }, submissionDeposit, tally, tallyTotal } = useMemo( () => expandOngoing(api, info, track), [api, info, track] ); - const preimage = usePreimage(proposalHash); + const preimage = usePreimage(ongoing.proposal || (ongoing as unknown as { proposalHash: Hash }).proposalHash); return ( <> @@ -98,7 +100,7 @@ function Ongoing ({ isMember, members, palletReferenda, palletVote, ranks, track withHash /> ) - :
{proposalHash}
+ :
{preimage?.proposalHash}
} >(paramsStatus && api.query.preimage?.statusFor, paramsStatus); + const optStatus = useCall>(!inlineData && paramsStatus && api.query.preimage?.statusFor, paramsStatus); // from the retrieved status (if any), get the on-chain stored bytes const { paramsBytes, resultPreimageFor } = useMemo(