Basic stuff

This commit is contained in:
MotorTruck1221
2025-03-18 00:52:29 -06:00
parent 19e6beaec4
commit a57072d6f8
8 changed files with 145 additions and 4 deletions
+49
View File
@@ -0,0 +1,49 @@
import { StoreManager } from "./storage";
class Settings {
#storageManager: StoreManager<"radius||settings">;
static #instance = new Set();
static async getInstance() {
function *get() {
for (const instance of Settings.#instance.keys()) {
yield instance!;
}
}
const ready = (): Promise<boolean> => {
return new Promise((resolve) => {
const i = setInterval(() => {
if (Settings.#instance.size !== 0) {
clearInterval(i);
resolve(true);
}
}, 100);
})
}
await ready();
return get().next().value! as Settings;
}
theme(theme: string) {
this.#storageManager.setVal('theme', theme);
theme === 'default'
? document.documentElement.className = ''
: document.documentElement.className = theme;
}
async *#init() {
yield this.theme(this.#storageManager.getVal('theme'));
}
constructor() {
this.#storageManager = new StoreManager("radius||settings");
Settings.#instance.add(this);
(async() => {
for await (const _ of this.#init());
})();
}
}
export { Settings }