fix: referenda list collapse issue (#11796)

This commit is contained in:
Arjun Porwal 2025-12-02 14:29:58 +05:30 committed by GitHub
parent ac0c27b36b
commit 350a0af003
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View File

@ -51,10 +51,10 @@ function sortGroups (a: ReferendaGroupKnown, b: ReferendaGroupKnown): number {
}
const OPT_MULTI = {
transform: ([[ids], all]: [[BN[]], Option<Referendum['info']>[]]) =>
ids.map((id, i) => {
transform: ([[ids], all]: [[BN[]], Option<Referendum['info']>[]]) => {
const res = ids.map((id, i) => {
const infoOpt = all[i];
const info = infoOpt?.isSome ? infoOpt.unwrap() : undefined;
const info = infoOpt.unwrap();
return {
id,
@ -62,7 +62,10 @@ const OPT_MULTI = {
isConvictionVote: info ? isConvictionVote(info) : false,
key: id.toString()
};
}).filter((r) => r.info !== undefined),
});
return res.filter((r) => r.info !== undefined);
},
withParamsTransform: true
};

View File

@ -11,7 +11,7 @@ import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks';
function calcActive (grouped: ReferendaGroup[] = []): number {
return grouped.reduce((total, { referenda = [] }) =>
total + referenda.filter((r) =>
r.info.isOngoing
r.info?.isOngoing
).length,
0);
}