Fix web UI crash when tie requires manual intervention in first stage

This commit is contained in:
RunasSudo 2021-10-29 20:28:25 +11:00
parent 5a652cb466
commit ba82828046
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 14 additions and 9 deletions

View File

@ -64,13 +64,7 @@ onmessage = function(evt) {
// Step election
state = wasm['CountState' + numbers].new(election);
wasm['count_init_' + numbers](state, opts);
postMessage({'type': 'updateResultsTable', 'result': wasm['update_results_table_' + numbers](1, state, opts, reportStyle)});
postMessage({'type': 'updateStageComments', 'comment': wasm['update_stage_comments_' + numbers](state)});
stageNum = 2;
stageNum = 1;
resumeCount();
} else if (evt.data.type == 'userInput') {
@ -92,7 +86,12 @@ onmessage = function(evt) {
function resumeCount() {
for (;; stageNum++) {
let isDone = wasm['count_one_stage_' + numbers](state, opts);
let isDone;
if (stageNum <= 1) {
isDone = wasm['count_init_' + numbers](state, opts);
} else {
isDone = wasm['count_one_stage_' + numbers](state, opts);
}
if (wasmRaw.asyncify_get_state() !== 0) {
// This stage caused a stack unwind in get_user_input so ignore the result

View File

@ -455,7 +455,13 @@ impl<'e, N: Number> TransferTable<'e, N> {
}
/// Render table as plain text
//#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(target_arch = "wasm32"))]
pub fn render_text(&self, opts: &STVOptions) -> String {
return self.render(opts).to_string();
}
/// Render table as HTML
#[cfg(target_arch = "wasm32")]
pub fn render_text(&self, opts: &STVOptions) -> String {
return self.render(opts).to_html();
}