Skip to content

Commit

Permalink
fix: remove delegate summary crash, add delegation identity (#2373)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Zhuravlev <[email protected]>
  • Loading branch information
johnthecat and Sergey Zhuravlev authored Sep 25, 2024
1 parent 79a2a00 commit 2ea3a06
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { combine, createEffect, createEvent, createStore, sample } from 'effecto
import { delegationService, votingsService } from '@/shared/api/governance';
import { type Address, type Chain, type ChainId } from '@/shared/core';
import { MONTH, getBlockTimeAgo, nonNullable, setNestedValue } from '@/shared/lib/utils';
import { type AggregatedReferendum, listAggregate, listService, networkSelectorModel } from '@/features/governance';
import {
type AggregatedReferendum,
listAggregate,
listService,
networkSelectorModel,
proposerIdentityAggregate,
} from '@/features/governance';
import { getDelegationsList } from '../lib/utils';

import { delegateDetailsModel } from './delegate-details-model';
Expand Down Expand Up @@ -140,11 +146,20 @@ sample({
target: $votedReferendumsMonth,
});

sample({
clock: $currentDelegations,
fn: (delegations) => ({
addresses: delegations.map(([address]) => address),
}),
target: proposerIdentityAggregate.events.requestProposers,
});

export const delegateSummaryModel = {
$isModalOpen,
$currentDelegations,
$votedReferendums,
$votedReferendumsMonth,
$proposers: proposerIdentityAggregate.$proposers,

$isDelegatingLoading: getDelegatesFx.pending,
$isReferendumsLoading: getReferendumsForVoterFx.pending,
Expand Down
9 changes: 5 additions & 4 deletions src/renderer/widgets/DelegateDetails/ui/DelegateSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const EmptyState = () => {
const DelegationsList = () => {
const { t } = useI18n();

const proposers = useUnit(delegateSummaryModel.$proposers);
const currentDelegations = useUnit(delegateSummaryModel.$currentDelegations);
const isDelegatingLoading = useUnit(delegateSummaryModel.$isDelegatingLoading);
const chain = useUnit(delegateDetailsModel.$chain);
Expand All @@ -120,7 +121,7 @@ const DelegationsList = () => {
{currentDelegations.map(([address, delegation]) => (
<div key={address} className="flex items-center justify-between py-2">
<BodyText className="flex-1">
<Address showIcon address={address} variant="full" iconSize={20} />
<Address showIcon address={address} title={proposers[address]?.parent.name} variant="full" iconSize={20} />
</BodyText>
<div className="mr-6 gap-y-1">
<BodyText className="text-right">
Expand Down Expand Up @@ -154,7 +155,7 @@ const DelegationReferendumList = ({ votedReferendums }: { votedReferendums: Vote
return <EmptyState />;
}

if (isReferendumsLoading) {
if (isReferendumsLoading || !network) {
return <Loading />;
}

Expand All @@ -172,8 +173,8 @@ const DelegationReferendumList = ({ votedReferendums }: { votedReferendums: Vote
{selectedReferendum && (
<ReferendumDetailsModal
referendum={selectedReferendum}
chain={network!.chain}
asset={network!.asset}
chain={network.chain}
asset={network.asset}
showActions={false}
onClose={() => setSelectedReferendum(null)}
onVoteRequest={() => {}}
Expand Down

0 comments on commit 2ea3a06

Please sign in to comment.