From 2ea3a069de31642f601e347e6ecaa76d408d6fce Mon Sep 17 00:00:00 2001 From: Sergey Zhuravlev Date: Wed, 25 Sep 2024 18:53:58 +0300 Subject: [PATCH] fix: remove delegate summary crash, add delegation identity (#2373) Co-authored-by: Sergey Zhuravlev --- .../model/delegate-summary-model.ts | 17 ++++++++++++++++- .../DelegateDetails/ui/DelegateSummary.tsx | 9 +++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/renderer/widgets/DelegateDetails/model/delegate-summary-model.ts b/src/renderer/widgets/DelegateDetails/model/delegate-summary-model.ts index 9c38754e00..f30c05bd27 100644 --- a/src/renderer/widgets/DelegateDetails/model/delegate-summary-model.ts +++ b/src/renderer/widgets/DelegateDetails/model/delegate-summary-model.ts @@ -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'; @@ -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, diff --git a/src/renderer/widgets/DelegateDetails/ui/DelegateSummary.tsx b/src/renderer/widgets/DelegateDetails/ui/DelegateSummary.tsx index 0ffe05e87f..77c7c195da 100644 --- a/src/renderer/widgets/DelegateDetails/ui/DelegateSummary.tsx +++ b/src/renderer/widgets/DelegateDetails/ui/DelegateSummary.tsx @@ -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); @@ -120,7 +121,7 @@ const DelegationsList = () => { {currentDelegations.map(([address, delegation]) => (
-
+
@@ -154,7 +155,7 @@ const DelegationReferendumList = ({ votedReferendums }: { votedReferendums: Vote return ; } - if (isReferendumsLoading) { + if (isReferendumsLoading || !network) { return ; } @@ -172,8 +173,8 @@ const DelegationReferendumList = ({ votedReferendums }: { votedReferendums: Vote {selectedReferendum && ( setSelectedReferendum(null)} onVoteRequest={() => {}}