Add preference

This commit is contained in:
nimbleghost 2023-06-28 17:39:40 +02:00
parent e607944ad1
commit 4828e3a691
4 changed files with 61 additions and 3 deletions

View file

@ -1,5 +1,11 @@
import db from "./db";
export const UI_MODE = {
DARK: "dark",
LIGHT: "light",
SYSTEM: "system",
};
class Prefs {
constructor(dbImpl) {
this.db = dbImpl;
@ -40,6 +46,15 @@ class Prefs {
async setWebPushEnabled(enabled) {
await this.db.prefs.put({ key: "webPushEnabled", value: enabled });
}
async uiMode() {
const uiMode = await this.db.prefs.get("uiMode");
return uiMode?.value ?? UI_MODE.SYSTEM;
}
async setUIMode(mode) {
await this.db.prefs.put({ key: "uiMode", value: mode });
}
}
const prefs = new Prefs(db());