Fix bug 731674 - One calendar item stays visible after multi or recurring item deletion in multi-day view. r=philipp,a=philipp
authorMichel Verbraak <info@1st-setup.nl>
Mon, 05 Mar 2012 19:34:10 +0100
changeset 10228 9f2a7e1b2d1af2bffbb79cdae5e591f8fc1c2126
parent 10227 1732edd4de3d0271fd00fa811beea98650958c99
child 10229 e6458d7f3aebff724a3d5b35c61ae77b1293483a
push id382
push usermozilla@kewis.ch
push dateMon, 05 Mar 2012 19:12:42 +0000
treeherdercomm-beta@9f2a7e1b2d1a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp, philipp
bugs731674
Fix bug 731674 - One calendar item stays visible after multi or recurring item deletion in multi-day view. r=philipp,a=philipp
calendar/base/content/calendar-multiday-view.xml
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -3416,38 +3416,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">