ntfy/web/src/app/Prefs.js

34 lines
899 B
JavaScript
Raw Normal View History

2022-03-02 21:16:30 +00:00
import db from "./db";
class Prefs {
2022-03-06 05:02:27 +00:00
async setSound(sound) {
db.prefs.put({key: 'sound', value: sound.toString()});
2022-03-02 21:16:30 +00:00
}
2022-03-06 05:02:27 +00:00
async sound() {
const sound = await db.prefs.get('sound');
2022-03-09 20:58:21 +00:00
return (sound) ? sound.value : "ding";
2022-03-02 21:16:30 +00:00
}
async setMinPriority(minPriority) {
db.prefs.put({key: 'minPriority', value: minPriority.toString()});
}
async minPriority() {
const minPriority = await db.prefs.get('minPriority');
return (minPriority) ? Number(minPriority.value) : 1;
}
async setDeleteAfter(deleteAfter) {
db.prefs.put({key:'deleteAfter', value: deleteAfter.toString()});
}
async deleteAfter() {
const deleteAfter = await db.prefs.get('deleteAfter');
return (deleteAfter) ? Number(deleteAfter.value) : 604800; // Default is one week
}
}
const prefs = new Prefs();
export default prefs;