Skip to content

Commit

Permalink
Fixed new API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dkildar committed Jun 7, 2024
1 parent 6dc7cc7 commit eed3027
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/common/features/polls/api/get-poll-details-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface GetPollDetailsQueryResponse {
choice_text: string;
votes?: { total_votes: number; hive_hp_incl_proxied: number | null };
}[];
poll_stats: { total_voting_accounts_num: number; total_hive_hp_incl_proxied: number | null };
poll_stats?: { total_voting_accounts_num: number; total_hive_hp_incl_proxied: number | null };
poll_trx_id: string;
poll_voters?: { name: string; choice_num: number }[];
post_body: string;
Expand Down
4 changes: 2 additions & 2 deletions src/common/features/polls/api/polls-votes-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export namespace PollsVotesManagement {
...choiceNums.map((num) => ({ name: activeUser!.username, choice_num: num }))
],
poll_stats: {
...data.poll_stats,
total_hive_hp_incl_proxied: data.poll_stats?.total_hive_hp_incl_proxied ?? 0,
total_voting_accounts_num:
data.poll_stats.total_voting_accounts_num +
(data.poll_stats?.total_voting_accounts_num ?? 0) +
(currentUserChoices.length - (existingVotes?.length ?? 0))
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export function PollOptionWithResults({ choice, activeChoices, entry, interpreta
[pollDetails.data?.poll_stats.total_voting_accounts_num]
);
const totalHp = useMemo(
() => pollDetails.data?.poll_stats.total_hive_hp_incl_proxied ?? 0,
[pollDetails.data?.poll_stats.total_hive_hp_incl_proxied]
() => pollDetails.data?.poll_stats?.total_hive_hp_incl_proxied ?? 0,
[pollDetails.data?.poll_stats?.total_hive_hp_incl_proxied]
);
const choiceHp = useMemo(
() =>
Expand Down
4 changes: 2 additions & 2 deletions src/common/features/polls/components/poll-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export function PollWidget({ poll, isReadOnly, entry, compact = false }: Props)
[pollDetails.data?.status, resultsMode, pollDetails.data?.poll_trx_id]
);
const isInterpretationSelectionDisabled = useMemo(
() => pollDetails.data?.poll_stats.total_hive_hp_incl_proxied === null,
[pollDetails.data?.poll_stats.total_hive_hp_incl_proxied]
() => pollDetails.data?.poll_stats?.total_hive_hp_incl_proxied === null,
[pollDetails.data?.poll_stats?.total_hive_hp_incl_proxied]
);

useEffect(() => {
Expand Down

0 comments on commit eed3027

Please sign in to comment.