Skip to content

Commit

Permalink
impr: changing keymap mode will no longer restart the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Miodec committed Sep 27, 2023
1 parent 8512441 commit 897cfde
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
5 changes: 4 additions & 1 deletion frontend/src/ts/elements/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export async function refresh(
}
}

ConfigEvent.subscribe((eventKey) => {
ConfigEvent.subscribe((eventKey, newValue) => {
if (eventKey === "layout" && Config.keymapLayout === "overrideSync") {
refresh(Config.keymapLayout);
}
Expand All @@ -335,6 +335,9 @@ ConfigEvent.subscribe((eventKey) => {
) {
refresh();
}
if (eventKey === "keymapMode") {
newValue === "off" ? hide() : show();
}
});

KeymapEvent.subscribe((mode, key, correct) => {
Expand Down
33 changes: 19 additions & 14 deletions frontend/src/ts/test/test-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,10 @@ export function restart(options = {} as RestartOptions): void {
TestUI.showWords();
if (Config.keymapMode === "next" && Config.mode !== "zen") {
KeymapEvent.highlight(
TestWords.words
.getCurrent()
.substring(
TestInput.input.current.length,
TestInput.input.current.length + 1
)
.toString()
Misc.nthElementFromArray(
[...TestWords.words.getCurrent()],
0
) as string
);
}
Funbox.toggleScript(TestWords.words.getCurrent());
Expand All @@ -361,12 +358,6 @@ export function restart(options = {} as RestartOptions): void {
TestState.setRepeated(false);
}

if (Config.keymapMode !== "off") {
Keymap.show();
} else {
Keymap.hide();
}

for (const f of FunboxList.get(Config.funbox)) {
if (f.functions?.restart) f.functions.restart();
}
Expand Down Expand Up @@ -1519,14 +1510,28 @@ ConfigEvent.subscribe((eventKey, eventValue, nosave) => {
if (ActivePage.get() === "test") {
if (eventKey === "difficulty" && !nosave) restart();
if (eventKey === "showAllLines" && !nosave) restart();
if (eventKey === "keymapMode" && !nosave) restart();
if (eventKey === "tapeMode" && !nosave) restart();
if (
eventKey === "customLayoutFluid" &&
Config.funbox.includes("layoutfluid")
) {
restart();
}

if (
eventKey === "keymapMode" &&
eventValue === "next" &&
Config.mode !== "zen"
) {
setTimeout(() => {
KeymapEvent.highlight(
Misc.nthElementFromArray(
[...TestWords.words.getCurrent()],
0
) as string
);
}, 0);
}
}
if (eventKey === "lazyMode" && eventValue === false && !nosave) {
rememberLazyMode = false;
Expand Down

0 comments on commit 897cfde

Please sign in to comment.