Skip to content

Commit

Permalink
fix: update store on response
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed May 21, 2024
1 parent 9eff6c8 commit a28e62d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export class InteractivityCenter implements HMSInteractivityCenter {
}
});
this.store.setPoll(pollCopy);
this.listener?.onPollsUpdate(HMSPollsUpdate.POLL_STATS_UPDATED, [pollCopy]);
}
async getPolls(): Promise<HMSPoll[]> {
const launchedPollsList = await this.transport.signal.getPollsList({ count: 50, state: 'started' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,21 @@ export const Voting = ({ id, toggleVoting }: { id: string; toggleVoting: () => v
if (poll && actions.interactivityCenter && !fetchedInitialResponses.current) {
await actions.interactivityCenter.getPollResponses(poll, true);
fetchedInitialResponses.current = true;
const pollResponses: Record<number, any> = {};
poll.questions?.forEach(question => {
pollResponses[question.index] = question.responses?.[0];
});
console.log('zzz updating', { pollResponses });
setSavedPollResponses(pollResponses);
}
};
getResponses();
}, [poll, actions.interactivityCenter, setSavedPollResponses]);

useEffect(() => {
if (poll?.questions) {
const pollResponses: Record<number, any> = {};
poll.questions?.forEach(question => {
pollResponses[question.index] = question.responses?.[0];
});
setSavedPollResponses(pollResponses);
}
}, [poll?.questions, setSavedPollResponses]);

if (!poll) {
return null;
}
Expand Down

0 comments on commit a28e62d

Please sign in to comment.