1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-04-14 11:18:47 +02:00
joplin/ReactNativeClient/lib/services/AlarmServiceDriverNode.js
2017-11-28 00:22:38 +00:00

34 lines
710 B
JavaScript

class AlarmServiceDriverNode {
constructor() {
this.notifications_ = {};
}
hasPersistentNotifications() {
return false;
}
notificationIsSet(id) {
return id in this.notifications_;
}
async clearNotification(id) {
if (!this.notificationIsSet(id)) return;
clearTimeout(this.notifications_[id].timeoutId);
delete this.notifications_[id];
}
async scheduleNotification(notification) {
const now = Date.now();
const interval = notification.date.getTime() - now;
if (interval < 0) return;
const timeoutId = setTimeout(() => {
console.info('NOTIFICATION: ', notification);
this.clearNotification(notification.id);
}, interval);
}
}
module.exports = AlarmServiceDriverNode;