Skip to content

Commit

Permalink
Fix for missing custom config in editrealmsconfig (#2280)
Browse files Browse the repository at this point in the history
  • Loading branch information
dankelleher committed May 14, 2024
1 parent 0ecb1c4 commit 2914a8b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions hub/components/EditRealmConfig/VotingStructureSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ interface Props {
}

function areConfigsEqual(a: Props['structure'], b: Props['structure']) {
if (
Object.hasOwnProperty.call(a, 'maxVotingProgramId') !==
Object.hasOwnProperty.call(b, 'maxVotingProgramId') ||
Object.hasOwnProperty.call(a, 'votingProgramId') !==
Object.hasOwnProperty.call(b, 'votingProgramId')
) {
return false;
}

if (
(a.maxVotingProgramId && !b.maxVotingProgramId) ||
(!a.maxVotingProgramId && b.maxVotingProgramId)
Expand Down Expand Up @@ -246,12 +255,10 @@ export function VotingStructureSelector(props: Props) {
ref={trigger}
>
<div className={labelStyles}>
{areConfigsEqual({}, props.structure) && isDefault
? 'Default'
: getLabel(props.structure)}
{isDefault ? 'Default' : getLabel(props.structure)}
</div>
<div className={descriptionStyles}>
{areConfigsEqual({}, props.structure) && isDefault
{isDefault
? 'Governance is based on token ownership'
: getDescription(props.structure)}
</div>
Expand Down Expand Up @@ -363,16 +370,15 @@ export function VotingStructureSelector(props: Props) {
...(props.allowNFT ? [DEFAULT_NFT_CONFIG] : []),
...(props.allowVSR ? [DEFAULT_VSR_CONFIG] : []),
...(props.allowQV ? [DEFAULT_QV_CONFIG] : []),
...(isCustomConfig(props.currentStructure)
...(isCustomConfig(props.currentStructure) && !isDefault
? [props.currentStructure]
: [{}]),
'default',
] as const)
.filter((config) => {
if (typeof config === 'string') {
return !areConfigsEqual({}, props.structure);
return !isDefault;
}

return !areConfigsEqual(config, props.structure);
})
.map((config, i) => (
Expand Down

0 comments on commit 2914a8b

Please sign in to comment.