Fix exception when preforming election without votes.

This commit is contained in:
armored-dragon 2024-09-10 15:38:41 -05:00
parent b6ab61a28f
commit 2b48831cb7
No known key found for this signature in database
GPG key ID: C7207ACC3382AD8B

View file

@ -16,10 +16,10 @@
// TODO: Sound for new vote
// TODO: Debug mode?
// FIXME: Handle ties
// FIXME: Running election without votes causes max stack error
// TODO: Voting results page
// TODO: Joining poll sometimes causes to double stack on other clients poll_list?
// FIXME: Closing application also prompts for user confirmation. Probably don't want that.
(() => {
"use strict";
@ -237,6 +237,9 @@
voteObject[firstVotes[i]]++
}
// Don't run election if we don't have any votes.
if (firstVotes.length == 0) return;
console.log(`Votes: ${JSON.stringify(voteObject, null, 4)}`);
// Check to see if there is a majority vote