diff --git a/frontend/src/ts/test/practise-words.ts b/frontend/src/ts/test/practise-words.ts index c02a6464e..14b3e22e6 100644 --- a/frontend/src/ts/test/practise-words.ts +++ b/frontend/src/ts/test/practise-words.ts @@ -10,16 +10,26 @@ import { isPopupVisible } from "../utils/misc"; const wrapperId = "practiseWordsPopupWrapper"; +interface BeforeCustomText { + text: string[]; + isTimeRandom: boolean; + isWordRandom: boolean; + time: number; + word: number; +} + interface Before { mode: MonkeyTypes.Mode | null; punctuation: boolean | null; numbers: boolean | null; + customText: BeforeCustomText | null; } export const before: Before = { mode: null, punctuation: null, numbers: null, + customText: null, }; export function init(missed: boolean, slow: boolean): boolean { @@ -91,8 +101,19 @@ export function init(missed: boolean, slow: boolean): boolean { const punctuation = before.punctuation === null ? Config.punctuation : before.punctuation; const numbers = before.numbers === null ? Config.numbers : before.numbers; - UpdateConfig.setMode("custom", true); + let customText = null; + if (Config.mode === "custom") { + customText = { + text: CustomText.text, + isWordRandom: CustomText.isWordRandom, + isTimeRandom: CustomText.isTimeRandom, + word: CustomText.word, + time: CustomText.time, + }; + } + + UpdateConfig.setMode("custom", true); CustomText.setPopupTextareaState(newCustomText.join(CustomText.delimiter)); CustomText.setText(newCustomText); CustomText.setIsWordRandom(true); @@ -107,6 +128,7 @@ export function init(missed: boolean, slow: boolean): boolean { before.mode = mode; before.punctuation = punctuation; before.numbers = numbers; + before.customText = customText; return true; } @@ -115,6 +137,7 @@ export function resetBefore(): void { before.mode = null; before.punctuation = null; before.numbers = null; + before.customText = null; } export function showPopup(focus = false): void { diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 2d4ed592d..9b6538001 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -464,6 +464,18 @@ export function restart(options = {} as RestartOptions): void { if (PractiseWords.before.numbers !== null) { UpdateConfig.setNumbers(PractiseWords.before.numbers); } + + if (PractiseWords.before.customText) { + CustomText.setText(PractiseWords.before.customText.text); + CustomText.setIsTimeRandom(PractiseWords.before.customText.isTimeRandom); + CustomText.setIsWordRandom(PractiseWords.before.customText.isWordRandom); + CustomText.setWord(PractiseWords.before.customText.word); + CustomText.setTime(PractiseWords.before.customText.time); + CustomText.setPopupTextareaState( + PractiseWords.before.customText.text.join(CustomText.delimiter) + ); + } + UpdateConfig.setMode(PractiseWords.before.mode); PractiseWords.resetBefore(); }