diff --git a/frontend/src/js/test/funbox.js b/frontend/src/js/test/funbox.js index f5f8063af..88d2ef78c 100644 --- a/frontend/src/js/test/funbox.js +++ b/frontend/src/js/test/funbox.js @@ -1,7 +1,5 @@ -import * as TestLogic from "./test-logic"; import * as TestWords from "./test-words"; import * as Notifications from "../elements/notifications"; -import * as TestUI from "./test-ui"; import * as Misc from "../misc"; import * as ManualRestart from "./manual-restart-tracker"; import Config, * as UpdateConfig from "../config"; @@ -121,7 +119,8 @@ export async function activate(funbox) { "Current language does not support this funbox mode", 0 ); - setFunbox("none", null); + UpdateConfig.setFunbox("none", true); + await clear(); return; } } @@ -133,14 +132,8 @@ export async function activate(funbox) { )} mode does not support the ${funbox} funbox`, 0 ); - setFunbox("none", null); - if (TestUI.testRestartingPromise) { - TestUI.testRestartingPromise.then(() => { - TestLogic.restart(false, true); - }); - } else { - TestLogic.restart(false, true); - } + UpdateConfig.setFunbox("none", true); + await clear(); return; } } @@ -167,7 +160,6 @@ export async function activate(funbox) { if (funbox === "simon_says") { UpdateConfig.setKeymapMode("next", true); - TestLogic.restart(false, true); } if ( @@ -176,14 +168,12 @@ export async function activate(funbox) { funbox === "read_ahead_hard" ) { UpdateConfig.setHighlightMode("letter", true); - TestLogic.restart(false, true); } } else if (mode === "script") { if (funbox === "tts") { $("#funBoxTheme").attr("href", `funbox/simon_says.css`); UpdateConfig.setKeymapMode("off", true); UpdateConfig.setHighlightMode("letter", true); - TestLogic.restart(false, true); } else if (funbox === "layoutfluid") { UpdateConfig.setLayout( Config.customLayoutfluid @@ -197,22 +187,18 @@ export async function activate(funbox) { : "qwerty", true ); - TestLogic.restart(false, true); } else if (funbox === "memory") { UpdateConfig.setMode("words", true); UpdateConfig.setShowAllLines(true, true); - TestLogic.restart(false, true); if (Config.keymapMode === "next") { UpdateConfig.setKeymapMode("react", true); } } else if (funbox === "nospace") { $("#words").addClass("nospace"); UpdateConfig.setHighlightMode("letter", true); - TestLogic.restart(false, true); } else if (funbox === "arrows") { $("#words").addClass("arrows"); UpdateConfig.setHighlightMode("letter", true); - TestLogic.restart(false, true); } } ModesNotice.update(); diff --git a/frontend/src/js/test/test-logic.js b/frontend/src/js/test/test-logic.js index 64b1954a0..8ea9a4bda 100644 --- a/frontend/src/js/test/test-logic.js +++ b/frontend/src/js/test/test-logic.js @@ -438,6 +438,17 @@ export function restart( UpdateConfig.setPunctuation(false, true); UpdateConfig.setNumbers(false, true); } + if ( + withSameWordset && + (Config.funbox === "plus_one" || Config.funbox === "plus_two") + ) { + Notifications.add( + "Sorry, this funbox won't work with repeated tests.", + 0, + 4 + ); + withSameWordset = false; + } if (!withSameWordset && !shouldQuoteRepeat) { TestState.setRepeated(false); TestState.setPaceRepeat(repeatWithPace); @@ -451,15 +462,6 @@ export function restart( Replay.stopReplayRecording(); TestWords.words.resetCurrentIndex(); TestInput.input.reset(); - if (Config.funbox === "plus_one" || Config.funbox === "plus_two") { - Notifications.add( - "Sorry, this funbox won't work with repeated tests.", - 0 - ); - await Funbox.clear(); - } else { - await Funbox.activate(); - } TestUI.showWords(); if (Config.keymapMode === "next" && Config.mode !== "zen") { Keymap.highlightKey( @@ -681,6 +683,10 @@ export async function init() { TestInput.input.resetHistory(); TestInput.input.resetCurrent(); + if (ActivePage.get() == "test") { + await Funbox.activate(); + } + let language = await Misc.getLanguage(Config.language); if (language && language.name !== Config.language) { UpdateConfig.setLanguage("english"); @@ -951,9 +957,6 @@ export async function init() { // $("#words").css("height", "auto"); // $("#wordsWrapper").css("height", "auto"); // } else { - if (ActivePage.get() == "test") { - await Funbox.activate(); - } TestUI.showWords(); if (Config.keymapMode === "next" && Config.mode !== "zen") { Keymap.highlightKey( @@ -1303,7 +1306,7 @@ export async function finish(difficultyFailed = false) { TimerProgress.hide(); OutOfFocus.hide(); TestTimer.clear(); - Funbox.activate("none", null); + Funbox.clear(); //need one more calculation for the last word if test auto ended if (TestInput.burstHistory.length !== TestInput.input.getHistory().length) {