From 24143cfe67e557036d8a4cc4bdab3011860a57b0 Mon Sep 17 00:00:00 2001 From: decaf Date: Thu, 19 Nov 2020 08:35:32 -0600 Subject: [PATCH] Fix "Bail Out" subcommands not hiding in single command mode --- src/js/commandline.js | 18 +++++++----------- src/js/misc.js | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/js/commandline.js b/src/js/commandline.js index 4059e6b2f..47d8ef888 100644 --- a/src/js/commandline.js +++ b/src/js/commandline.js @@ -575,6 +575,9 @@ let commands = { exec: () => { hideCommandLine(); }, + available: () => { + return canBailOut(); + }, }, { id: "bailOutForSure", @@ -583,23 +586,16 @@ let commands = { bailout = true; showResult(); }, + available: () => { + return canBailOut(); + }, }, ], }); showCommandLine(); }, available: () => { - return ( - (config.mode === "custom" && - customTextIsRandom && - customTextWordCount >= 5000) || - (config.mode === "custom" && - !customTextIsRandom && - customText.length >= 5000) || - (config.mode === "words" && config.words >= 5000) || - config.words === 0 || - (config.mode === "time" && (config.time >= 3600 || config.time === 0)) - ); + return canBailOut(); }, }, { diff --git a/src/js/misc.js b/src/js/misc.js index 31481088d..bfd61d010 100644 --- a/src/js/misc.js +++ b/src/js/misc.js @@ -511,6 +511,20 @@ function toggleFullscreen(elem) { } } +function canBailOut() { + return ( + (config.mode === "custom" && + customTextIsRandom && + customTextWordCount >= 5000) || + (config.mode === "custom" && + !customTextIsRandom && + customText.length >= 5000) || + (config.mode === "words" && config.words >= 5000) || + config.words === 0 || + (config.mode === "time" && (config.time >= 3600 || config.time === 0)) + ); +} + let simplePopups = {}; class SimplePopup {