shared/scripts/lib/notifications.js
/**
 * Schedule a new notification.
 *
 * @param {number} when - time as a moment object or unix timestamp.
 * @param {number} days - how many days until the next notification.
 */
Schedule a new notification.
@param {number} when - time as a moment object or unix timestamp.
@param {number} days - how many days until the next notification.
Schedule a new notification . @param { number } when - time as a moment object or unix timestamp . @param { number } days - how many days until the next notification .
function create(name, when, days) {
  var minutes = null;
  if (environment === 'chrome') {
    minutes = days * (24 * 60);
    chrome.alarms.create(name, {
      when: Number(when),
      periodInMinutes: minutes
    });
  }
  else if (environment === 'firefox') {
    self.port.emit('notification.set', when);
  }
}
function create ( name , when , days ) { var minutes = null ; if ( environment === 'chrome' ) { minutes = days * ( 24 * 60 ) ; chrome . alarms . create ( name , { when : Number ( when ) , periodInMinutes : minutes } ) ; } else if ( environment === 'firefox' ) { self . port . emit ( 'notification.set' , when ) ; } }
Schedule a new notification.
Schedule a new notification .
// Convert the repeating days to minutes. // When using the same name, Chrome will automatically clear out the previous // notification. // In Firefox, the extension library cannot trigger a notification, so // instead we let the background script handle it.  Just need to let the // extension know when the right time is to trigger.