-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add touch * update css * add lowerdebouncetime * add settings cache * organize imports
- Loading branch information
Showing
6 changed files
with
50 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { DEBOUNCE_TIME, DEBOUNCE_TIME_LOWER } from "../constants.js"; | ||
import { SettingsUtils } from "./settings-utils.js"; | ||
|
||
export class PerformanceUtils { | ||
static getDebounceTime() { | ||
if (SettingsUtils.get("editor:lower-debounce-time")) { | ||
return DEBOUNCE_TIME_LOWER; | ||
} | ||
return DEBOUNCE_TIME; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import { LOCALSTORAGE_SETTINGS, SETTING_DEFAULTS, SETTING_KEYS } from "../constants"; | ||
|
||
const cache: Map<string, boolean> = new Map(); | ||
|
||
export class SettingsUtils { | ||
static get(settingKey: (typeof SETTING_KEYS)[number]): boolean { | ||
const key = LOCALSTORAGE_SETTINGS + settingKey; | ||
if (cache.has(key)) { | ||
return cache.get(key) as boolean; | ||
} | ||
const item = localStorage.getItem(key); | ||
let value = item === "1"; | ||
if (item === null) { | ||
return SETTING_DEFAULTS[settingKey]; | ||
value = SETTING_DEFAULTS[settingKey]; | ||
} | ||
return item === "1"; | ||
cache.set(key, value); | ||
return value; | ||
} | ||
|
||
static set(settingKey: (typeof SETTING_KEYS)[number], value: boolean) { | ||
const key = LOCALSTORAGE_SETTINGS + settingKey; | ||
localStorage.setItem(key, value ? "1" : "0"); | ||
cache.set(key, value); | ||
} | ||
} |