Skip to content

Commit

Permalink
Update poll numbers after voting
Browse files Browse the repository at this point in the history
  • Loading branch information
micahlt committed Sep 11, 2024
1 parent 7da7e82 commit 60bbc33
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/Poll.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function Poll({ poll }) {
const setVote = choiceIndex => {
if (localPoll.participated) {
ToastAndroid.show('You cannot change your vote', ToastAndroid.SHORT);
return;
}
API.voteOnPoll(localPoll.id, choiceIndex).then(() => {
setLocalPoll({
Expand All @@ -29,6 +30,7 @@ function Poll({ poll }) {
choices: localPoll.choices.map((choice, index) => ({
...choice,
selected: index === choiceIndex,
count: index === choiceIndex ? choice.count + 1 : choice.count,
})),
});
});
Expand Down

0 comments on commit 60bbc33

Please sign in to comment.