mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-05-19 11:53:26 +12:00
ff5c854192
- Use new notification request/opt-in flow for push - Implement unsubscribing - Implement muting - Implement emojis in title - Add iOS specific PWA warning - Don’t use websockets when web push is enabled - Fix duplicate notifications - Implement default web push setting - Implement changing subscription type - Implement web push subscription refresh - Implement web push notification click
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import getDb from "./getDb";
|
|
|
|
class Prefs {
|
|
constructor(db) {
|
|
this.db = db;
|
|
}
|
|
|
|
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) {
|
|
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 webPushDefaultEnabled() {
|
|
const obj = await this.db.prefs.get("webPushDefaultEnabled");
|
|
return obj?.value ?? "initial";
|
|
}
|
|
|
|
async setWebPushDefaultEnabled(enabled) {
|
|
await this.db.prefs.put({ key: "webPushDefaultEnabled", value: enabled ? "enabled" : "disabled" });
|
|
}
|
|
}
|
|
|
|
export default new Prefs(getDb());
|