From efb5879aba6d9d964e810a87fb8143be66592609 Mon Sep 17 00:00:00 2001 From: Franco Reyes Date: Wed, 2 Oct 2024 00:00:52 +1000 Subject: [PATCH] Avoid sleeping on abstain votes --- src/App.tsx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 58a8917..b3d33e0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -75,19 +75,20 @@ function App() { const initialiseRound = async () => { for (let i = 0; i < init.votes.length; i++) { - setDistribution(distribution => { - const vote = cloneDeep(init.votes[i]); - const newDistribution = cloneDeep(distribution); - while (vote.length && eliminated.includes(vote[0])) { - vote.shift(); - } - if (vote.length && vote[0] != NONE) { + const vote = cloneDeep(init.votes[i]); + while (vote.length && eliminated.includes(vote[0])) { + vote.shift(); + } + + if (vote.length && vote[0] != NONE) { + setDistribution(distribution => { + const newDistribution = cloneDeep(distribution); newDistribution[vote[0]].push(vote); - } - return newDistribution; - }); + return newDistribution; + }); - await sleep(speed); + await sleep(speed); + } } };