Bug 496897 - an exception occurs when closing the alarm window containing alarms for several occurences of the same event. r=philipp, a=philipp
authorMatthew Mecca <matthew.mecca@gmail.com>
Sun, 23 Oct 2011 18:59:39 -0400
changeset 8936 365a0c5882127e6c36c0ca1fe4a1e0ec19aa9778
parent 8935 42823bfd0f82b27e3c82d50ef0dd567e291a980b
child 8938 aef75ee474074d34a0f5cc3e6eddab6a0ecc5fa1
push id195
push usermatthew.mecca@gmail.com
push dateSun, 23 Oct 2011 23:20:47 +0000
treeherdercomm-beta@365a0c588212 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp, philipp
bugs496897
Bug 496897 - an exception occurs when closing the alarm window containing alarms for several occurences of the same event. r=philipp, a=philipp
calendar/base/content/dialogs/calendar-alarm-dialog.js
--- a/calendar/base/content/dialogs/calendar-alarm-dialog.js
+++ b/calendar/base/content/dialogs/calendar-alarm-dialog.js
@@ -78,21 +78,25 @@ function onDismissAlarm(event) {
 }
 
 /**
  * Called to dismiss all alarms in the alarm window.
  */
 function onDismissAllAlarms() {
     // removes widgets on the fly:
     let alarmRichlist = document.getElementById("alarm-richlist");
+    let parentItems = {};
 
     // Make a copy of the child nodes as they get modified live
     for each (let node in Array.slice(alarmRichlist.childNodes)) {
         // Check if the node is a valid alarm and is still part of DOM
-        if (node.parentNode && node.item && node.alarm) {
+        if (node.parentNode && node.item && node.alarm &&
+            !(node.item.parentItem.hashId in parentItems)) {
+            // We only need to acknowledge one occurrence for repeating items
+            parentItems[node.item.parentItem.hashId] = node.item.parentItem;
             getAlarmService().dismissAlarm(node.item, node.alarm);
         }
     }
 }
 
 /**
  * Event handler fired when the alarm widget's "Details..." label was clicked.
  * Open the event dialog in the most recent Sunbird or Thunderbird window
@@ -183,21 +187,25 @@ function updateRelativeDates() {
  * @param aDurationMinutes    The duration in minutes
  */
 function snoozeAllItems(aDurationMinutes) {
     let duration = cal.createDuration();
     duration.minutes = aDurationMinutes;
     duration.normalize();
 
     let alarmRichlist = document.getElementById("alarm-richlist");
+    let parentItems = {};
 
     // Make a copy of the child nodes as they get modified live
     for each (let node in Array.slice(alarmRichlist.childNodes)) {
         // Check if the node is a valid alarm and is still part of DOM
-        if (node.parentNode && node.item && node.alarm) {
+        if (node.parentNode && node.item && node.alarm &&
+            !(node.item.parentItem.hashId in parentItems)) {
+            // We only need to acknowledge one occurrence for repeating items
+            parentItems[node.item.parentItem.hashId] = node.item.parentItem;
             getAlarmService().snoozeAlarm(node.item, node.alarm, duration);
         }
     }
 }
 
 /**
  * Sets up the window title, counting the number of alarms in the window.
  */