mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: Show every voter only once. (#6746)
Each voter is represented by an object and Set does not properly check for equality.
This commit is contained in:

committed by
Régis Hanol

parent
2ee2e5c981
commit
285ff3bfbd
@ -117,7 +117,14 @@ createWidget("discourse-poll-voters", {
|
||||
attrs.pollType === "number"
|
||||
? result.voters
|
||||
: result.voters[attrs.optionId];
|
||||
state.voters = [...new Set([...state.voters, ...newVoters])];
|
||||
|
||||
const existingVoters = new Set(state.voters.map(voter => voter.username));
|
||||
newVoters.forEach(voter => {
|
||||
if (!existingVoters.has(voter.username)) {
|
||||
existingVoters.add(voter.username);
|
||||
state.voters.push(voter);
|
||||
}
|
||||
});
|
||||
|
||||
this.scheduleRerender();
|
||||
});
|
||||
|
Reference in New Issue
Block a user