mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-09-29 08:41:35 +13:00
a8d3297c4e
- Also handle notification permission changes - Remove web push schedule worker since this complicates things and doesn’t do _that_ much. We have the reminder notification if the user truly doesn’t reload ntfy in more than a week.
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import db from "./db";
|
|
|
|
class Prefs {
|
|
constructor(dbImpl) {
|
|
this.db = dbImpl;
|
|
}
|
|
|
|
async setSound(sound) {
|
|
this.db.prefs.put({ key: "sound", value: sound.toString() });
|
|
}
|
|
|
|
async sound() {
|
|
const sound = await this.db.prefs.get("sound");
|
|
return sound ? sound.value : "ding";
|
|
}
|
|
|
|
async setMinPriority(minPriority) {
|
|
this.db.prefs.put({ key: "minPriority", value: minPriority.toString() });
|
|
}
|
|
|
|
async minPriority() {
|
|
const minPriority = await this.db.prefs.get("minPriority");
|
|
return minPriority ? Number(minPriority.value) : 1;
|
|
}
|
|
|
|
async setDeleteAfter(deleteAfter) {
|
|
await this.db.prefs.put({ key: "deleteAfter", value: deleteAfter.toString() });
|
|
}
|
|
|
|
async deleteAfter() {
|
|
const deleteAfter = await this.db.prefs.get("deleteAfter");
|
|
return deleteAfter ? Number(deleteAfter.value) : 604800; // Default is one week
|
|
}
|
|
|
|
async webPushEnabled() {
|
|
const webPushEnabled = await this.db.prefs.get("webPushEnabled");
|
|
return webPushEnabled?.value;
|
|
}
|
|
|
|
async setWebPushEnabled(enabled) {
|
|
await this.db.prefs.put({ key: "webPushEnabled", value: enabled });
|
|
}
|
|
}
|
|
|
|
const prefs = new Prefs(db());
|
|
export default prefs;
|