mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-13 20:00:16 +00:00
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
export class UserSettings {
|
|
private focusedLocked_: boolean | null = null;
|
|
|
|
get(key: string, defaultValue: boolean) {
|
|
const value = localStorage.getItem(key);
|
|
if (!value) return defaultValue;
|
|
|
|
if (value === "true") return true;
|
|
|
|
if (value === "false") return false;
|
|
}
|
|
|
|
set(key: string, value: boolean) {
|
|
localStorage.setItem(key, value ? "true" : "false");
|
|
}
|
|
|
|
emojis() {
|
|
return this.get("settings.emojis", true);
|
|
}
|
|
|
|
darkMode() {
|
|
return this.get("settings.darkMode", false);
|
|
}
|
|
|
|
leftClickOpensMenu() {
|
|
return this.get("settings.leftClickOpensMenu", false);
|
|
}
|
|
|
|
focusLocked() {
|
|
if (this.focusedLocked_ === null) {
|
|
this.focusedLocked_ = this.get("settings.focusLocked", true);
|
|
}
|
|
return this.focusedLocked_;
|
|
}
|
|
|
|
toggleLeftClickOpenMenu() {
|
|
this.set("settings.leftClickOpensMenu", !this.leftClickOpensMenu());
|
|
}
|
|
|
|
toggleFocusLocked() {
|
|
this.focusLocked = null;
|
|
this.set("settings.focusLocked", !this.focusLocked());
|
|
}
|
|
|
|
toggleEmojis() {
|
|
this.set("settings.emojis", !this.emojis());
|
|
}
|
|
|
|
toggleDarkMode() {
|
|
this.set("settings.darkMode", !this.darkMode());
|
|
if (this.darkMode()) {
|
|
document.documentElement.classList.add("dark");
|
|
} else {
|
|
document.documentElement.classList.remove("dark");
|
|
}
|
|
}
|
|
}
|