Skip to content

Commit

Permalink
Fix: delegate after revoke (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
Asmadek authored Aug 22, 2024
1 parent 2eba3e1 commit 8d84a35
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/renderer/shared/api/governance/off-chain/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export type DelegateDetails = {
export type DelegateStat = {
// Address actually
accountId: Address;
delegators: any[];
delegatorVotes: any[];
delegators: number;
delegatorVotes: string;
delegateVotes: number;
};

Expand Down
1 change: 1 addition & 0 deletions src/renderer/shared/core/types/voting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type StandardVote = {
vote: {
aye: boolean;
conviction: Conviction;
// TODO: Add new type for decoded mst tx
vote?: 'Aye' | 'Nay';
};
balance: BN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ sample({
target: $isDelegationsOpen,
});

sample({
clock: $activeAccounts,
filter: ($activeAccounts) => $activeAccounts.length === 0,
target: $isDelegationsOpen.reinit,
});

export const delegateDetailsModel = {
$isModalOpen,
$delegate,
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/widgets/DelegateDetails/ui/YourDelegations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const YourDelegations = () => {
const account = wallet?.accounts.find((a) => toAddress(a.accountId) === address);
const activeDelegation = activeDelegations[address];

if (!account || !activeDelegation) return null;
if (!account || !activeDelegation || !activeTracks[address]) return null;

return (
<div key={address} className="flex h-[52px] items-center">
Expand Down Expand Up @@ -107,7 +107,7 @@ export const YourDelegations = () => {
pointer="up"
>
<div className="flex gap-1">
<FootnoteText>{activeTracks[address]?.size || 0}</FootnoteText>
<FootnoteText>{activeTracks[address].size || 0}</FootnoteText>

<Icon className="group-hover:text-icon-hover" name="info" size={16} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ sample({
fn: (delegate) =>
({
accountId: delegate,
delegators: [],
delegatorVotes: [],
delegators: 0,
delegatorVotes: '0',
delegateVotes: 0,
}) as DelegateAccount,
target: delegateModel.events.flowStarted,
Expand Down

0 comments on commit 8d84a35

Please sign in to comment.