Skip to content

Commit

Permalink
impr(typing): remember lazy mode choice when typing arabic in local s…
Browse files Browse the repository at this point in the history
…torage

closes monkeytypegame#4948
  • Loading branch information
Miodec committed Jan 22, 2024
1 parent 62c23e7 commit 487d0fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions frontend/src/ts/states/arabic-lazy-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function get(): boolean {
return (localStorage.getItem("prefersArabicLazyMode") ?? "true") === "true";
}

export function set(value: boolean): void {
localStorage.setItem(
"prefersArabicLazyMode",
value === true ? "true" : "false"
);
}
15 changes: 12 additions & 3 deletions frontend/src/ts/test/test-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import * as MemoryFunboxTimer from "./funbox/memory-funbox-timer";
import * as KeymapEvent from "../observables/keymap-event";
import * as LayoutfluidFunboxTimer from "../test/funbox/layoutfluid-funbox-timer";
import * as Wordset from "./wordset";
import * as ArabicLazyMode from "../states/arabic-lazy-mode";

let failReason = "";
const koInputVisual = document.getElementById("koInputVisual") as HTMLElement;
Expand Down Expand Up @@ -1521,7 +1522,10 @@ ConfigEvent.subscribe((eventKey, eventValue, nosave) => {
if (ActivePage.get() === "test") {
if (eventKey === "language") {
//automatically enable lazy mode for arabic
if ((eventValue as string)?.startsWith("arabic")) {
if (
(eventValue as string)?.startsWith("arabic") &&
ArabicLazyMode.get()
) {
UpdateConfig.setLazyMode(true, true);
}
restart();
Expand Down Expand Up @@ -1551,8 +1555,13 @@ ConfigEvent.subscribe((eventKey, eventValue, nosave) => {
}, 0);
}
}
if (eventKey === "lazyMode" && eventValue === false && !nosave) {
rememberLazyMode = false;
if (eventKey === "lazyMode" && !nosave) {
if (Config.language.startsWith("arabic")) {
ArabicLazyMode.set(eventValue as boolean);
}
if (eventValue === false) {
rememberLazyMode = false;
}
}
});

Expand Down

0 comments on commit 487d0fe

Please sign in to comment.