Skip to content
Snippets Groups Projects
Unverified Commit 88df7c75 authored by Jaco's avatar Jaco Committed by GitHub
Browse files

Adjust active referendum count (only isOngoing) (#8499)

parent 5c1a8ffb
No related branches found
No related tags found
1 merge request!3Xx network integration
......@@ -8,12 +8,19 @@ import { useMemo } from 'react';
import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
// TODO keep track of all tracks to get the number of deciding
function calcActive (grouped: ReferendaGroup[] = []): number {
return grouped.reduce((total, { referenda = [] }) =>
total + referenda.filter((r) =>
r.info.isOngoing
).length,
0);
}
function useSummaryImpl (palletReferenda: PalletReferenda, grouped?: ReferendaGroup[] | undefined): Summary {
const { api } = useApi();
const refCount = useCall<u32>(api.query[palletReferenda].referendumCount);
const refActive = useMemo(
() => grouped && grouped.reduce((total, { referenda }) => total + (referenda ? referenda.length : 0), 0),
() => calcActive(grouped),
[grouped]
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment