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:45:31 -0400
changeset 9304 5b6c8298edbca75ed3b7339162ff2e789ee0475e
parent 9303 2ea09fa04b871bf7c88617edfd1e14287b609753
child 9305 a1eee289974e643a3d478a32ae25178df8f2fa61
push id230
push userbugzilla@standard8.plus.com
push dateTue, 08 Nov 2011 22:55:24 +0000
treeherdercomm-beta@63dad5648415 [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.
  */