Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/page-referenda/src/useReferenda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@ 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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that a problem will not occur if infoOpt is undefined? Why are we removing the isSome() check before unwrapping the value

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wherever info is getting used, it makes sure it is not undefined, so It wouldn't break anything. Actually, I am getting back to original implementation here, so removed that isSome check.


return {
id,
info,
isConvictionVote: info ? isConvictionVote(info) : false,
key: id.toString()
};
}).filter((r) => r.info !== undefined),
});

return res.filter((r) => r.info !== undefined);
},
withParamsTransform: true
};

Expand Down
2 changes: 1 addition & 1 deletion packages/page-referenda/src/useSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down