mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 18:02:46 +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:
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();
|
||||
});
|
||||
|
|
|
@ -1344,7 +1344,7 @@ test("Public poll", async assert => {
|
|||
|
||||
assert.equal(
|
||||
find(".poll-voters:first li").length,
|
||||
50,
|
||||
26,
|
||||
"it should display the right number of voters"
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user