1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/ReactNativeClient/lib/services/AlarmServiceDriverNode.js

34 lines
710 B
JavaScript
Raw Normal View History

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;