Bug 701659 - Alarms fire but cannot be removed from the Alarm Dialog for occurrences of repeating items starting more than 6 hours in the future. r=philipp,a=philipp CAL80_20111117_RELBRANCH
authorMatthew Mecca <matthew.mecca@gmail.com>
Thu, 17 Nov 2011 23:53:34 +0100
branchCAL80_20111117_RELBRANCH
changeset 9370 e51dd73ebf3af226d3adf0a8f44c038be3a35140
parent 9368 6a3f64e02e7698021317a62b30709e136e689e10
child 9371 baaec1696e1be31caa8144d9d310d72129dbb08b
push idunknown
push userunknown
push dateunknown
reviewersphilipp, philipp
bugs701659
Bug 701659 - Alarms fire but cannot be removed from the Alarm Dialog for occurrences of repeating items starting more than 6 hours in the future. r=philipp,a=philipp
calendar/base/src/calAlarmService.js
--- a/calendar/base/src/calAlarmService.js
+++ b/calendar/base/src/calAlarmService.js
@@ -128,16 +128,17 @@ function calAlarmService() {
             // dismissing those alarms may write data...
             this.alarmService.unobserveCalendar(aCalendar);
         },
         onCalendarDeleting: function(aCalendar) {}
     };
 }
 
 calAlarmService.prototype = {
+    mRangeStart: null,
     mRangeEnd: null,
     mUpdateTimer: null,
     mStarted: false,
     mTimerMap: null,
     mObservers: null,
     mTimezone: null,
 
     getInterfaces: function cAS_getInterfaces(aCount) {
@@ -284,16 +285,17 @@ calAlarmService.prototype = {
                 let start;
                 if (!this.alarmService.mRangeEnd) {
                     // This is our first search for alarms.  We're going to look for
                     // alarms +/- 1 month from now.  If someone sets an alarm more than
                     // a month ahead of an event, or doesn't start Sunbird/Lightning
                     // for a month, they'll miss some, but that's a slim chance
                     start = now.clone();
                     start.month -= 1;
+                    this.alarmService.mRangeStart = start.clone();
                 } else {
                     // This is a subsequent search, so we got all the past alarms before
                     start = this.alarmService.mRangeEnd.clone();
                 }
                 let until = now.clone();
                 until.month += 1;
 
                 // We don't set timers for every future alarm, only those within 6 hours
@@ -442,21 +444,22 @@ calAlarmService.prototype = {
         // Purge alarms specifically for this item (i.e exception)
         for each (let alarm in aItem.getAlarms({})) {
             this.removeTimer(aItem, alarm);
         }
     },
 
     getOccurrencesInRange: function cAS_getOccurrencesInRange(aItem) {
         if (aItem && aItem.recurrenceInfo) {
-            let start = this.mRangeEnd.clone();
             // We search 1 month in each direction for alarms.  Therefore,
-            // we need to go back 2 months from the end to get this right.
-            start.month -= 2;
-            return aItem.recurrenceInfo.getOccurrences(start, this.mRangeEnd, 0, {});
+            // we need occurrences between initial start date and 1 month from now
+            let until = nowUTC();
+            until.month += 1;
+
+            return aItem.recurrenceInfo.getOccurrences(this.mRangeStart, until, 0, {});
         } else {
             return [aItem];
         }
     },
 
     addAlarmsForOccurrences: function cAS_addAlarmsForOccurrences(aParentItem) {
         let occs = this.getOccurrencesInRange(aParentItem);