impr(typing): remember lazy mode choice when typing arabic in local storage

closes #4948
This commit is contained in:
Miodec 2024-01-22 14:48:44 +01:00
parent 62c23e78b7
commit 487d0feacc
2 changed files with 22 additions and 3 deletions

View file

@ -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"
);
}

View file

@ -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;
@ -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();
@ -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;
}
}
});