diff --git a/src/common/features/polls/api/get-poll-details-query.ts b/src/common/features/polls/api/get-poll-details-query.ts index facf6fca72b..290087e61bd 100644 --- a/src/common/features/polls/api/get-poll-details-query.ts +++ b/src/common/features/polls/api/get-poll-details-query.ts @@ -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; diff --git a/src/common/features/polls/api/polls-votes-management.ts b/src/common/features/polls/api/polls-votes-management.ts index e2f4afc1a7a..6ebb303ac11 100644 --- a/src/common/features/polls/api/polls-votes-management.ts +++ b/src/common/features/polls/api/polls-votes-management.ts @@ -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)) } }; diff --git a/src/common/features/polls/components/poll-option-with-results.tsx b/src/common/features/polls/components/poll-option-with-results.tsx index bc93aa09156..ba5a106e80f 100644 --- a/src/common/features/polls/components/poll-option-with-results.tsx +++ b/src/common/features/polls/components/poll-option-with-results.tsx @@ -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( () => diff --git a/src/common/features/polls/components/poll-widget.tsx b/src/common/features/polls/components/poll-widget.tsx index c703a5161f8..b5c71b7c783 100644 --- a/src/common/features/polls/components/poll-widget.tsx +++ b/src/common/features/polls/components/poll-widget.tsx @@ -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(() => {