Fix bug 731674 - One calendar item stays visible after multi or recurring item deletion in multi-day view. r=philipp
authorMichel Verbraak <info@1st-setup.nl>
Mon, 05 Mar 2012 19:34:10 +0100
changeset 11001 d09df293d75e7585d16fd45618cd91206814aa94
parent 11000 9f6c12aa2efb04d6b2c5104d4f6c89953bf070a7
child 11002 62bcac2b45b7672338550e7183f3f5e5ad6b27e4
push id463
push userbugzilla@standard8.plus.com
push dateTue, 24 Apr 2012 17:34:51 +0000
treeherdercomm-beta@e53588e8f7b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs731674
Fix bug 731674 - One calendar item stays visible after multi or recurring item deletion in multi-day view. r=philipp
calendar/base/content/calendar-multiday-view.xml
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -3556,38 +3556,37 @@
 
       <method name="doDeleteItem">
         <parameter name="aEvent"/>
         <body><![CDATA[
           var cols = this.findColumnsForItem(aEvent);
           if (!cols.length)
               return;
 
+          function isNotItem(a) {
+              return (a.hashId != aEvent.hashId);
+          }
+          var oldLength = this.mSelectedItems.length;
+          this.mSelectedItems = this.mSelectedItems.filter(isNotItem);
+
           for each (let col in cols) {
               var column = col.column;
               var header = col.header;
 
               var estart = aEvent.startDate || aEvent.entryDate;
               if (estart.isDate) {
                   header.deleteEvent(aEvent);
               } else {
                   column.deleteEvent(aEvent);
               }
           }
 
-          // See whether the item we are deleting was selected.  If it was, then
-          // fire the appropriate event so our watchers can update
-          var found = false;
-          for (var i = 0; i < this.mSelectedItems.length; i++) {
-              if (this.mSelectedItems[i].hashId == aEvent.hashId) {
-                  this.mSelectedItems.splice(i, 1);
-                  found = true;
-              }
-          }
-          if (found) {
+          // If a deleted event was selected, we need to announce that the
+          // selection changed.
+          if (oldLength != this.mSelectedItems.length) {
               this.fireEvent("itemselect", this.mSelectedItems);
           }
 
           this.adjustScrollbarSpacersForAlldayEvents(aEvent);
         ]]></body>
       </method>
 
       <method name="deleteItemsFromCalendar">