Skip to content

Commit 9bb3cab

Browse files
committed
fix: answers for anonymous polls
1 parent 71c208a commit 9bb3cab

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

package/src/components/Poll/hooks/usePollAnswersPagination.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ export const usePollAnswersPagination = ({
5656
if (event.poll?.id && event.poll.id !== poll.id) return;
5757
const vote = event.poll_vote;
5858
if (vote && isVoteAnswer(vote)) {
59-
setPollAnswers([
60-
vote,
61-
...pollAnswers.filter((answer) => answer.user_id !== vote.user_id),
62-
]);
59+
setPollAnswers([vote, ...pollAnswers.filter((answer) => answer.id !== vote.id)]);
6360
}
6461
}),
6562
);
@@ -68,7 +65,7 @@ export const usePollAnswersPagination = ({
6865
if (event.poll?.id && event.poll.id !== poll.id) return;
6966
const vote = event.poll_vote;
7067
if (vote && isVoteAnswer(vote)) {
71-
setPollAnswers(pollAnswers.filter((item) => item.user_id !== vote.user_id));
68+
setPollAnswers(pollAnswers.filter((item) => item.id !== vote.id));
7269
}
7370
});
7471

package/src/components/Poll/hooks/usePollOptionVotesPagination.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export const usePollOptionVotesPagination = ({
6060
const vote = event.poll_vote;
6161
if (vote && !isVoteAnswer(vote)) {
6262
if (vote.option_id === option.id) {
63-
setVotes([vote, ...votes.filter((v) => v.user_id !== vote.user_id)]);
63+
setVotes([vote, ...votes.filter((v) => v.id !== vote.id)]);
6464
} else if (eventName === 'poll.vote_changed') {
65-
setVotes(votes.filter((v) => v.user_id !== vote.user_id));
65+
setVotes(votes.filter((v) => v.id !== vote.id));
6666
}
6767
}
6868
}),
@@ -72,7 +72,7 @@ export const usePollOptionVotesPagination = ({
7272
if (event.poll?.id && event.poll.id !== poll.id) return;
7373
const vote = event.poll_vote;
7474
if (vote && !isVoteAnswer(vote) && vote.option_id === option.id) {
75-
setVotes(votes.filter((v) => v.user_id !== vote.user_id));
75+
setVotes(votes.filter((v) => v.id !== vote.id));
7676
}
7777
});
7878

0 commit comments

Comments
 (0)