ntfy/web/src/app/Prefs.js

34 lines
1 KiB
JavaScript
Raw Normal View History

2022-03-02 21:16:30 +00:00
import db from "./db";
class Prefs {
async setSelectedSubscriptionId(selectedSubscriptionId) {
db.prefs.put({key: 'selectedSubscriptionId', value: selectedSubscriptionId});
}
async selectedSubscriptionId() {
const selectedSubscriptionId = await db.prefs.get('selectedSubscriptionId');
return (selectedSubscriptionId) ? selectedSubscriptionId.value : "";
}
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;