Fix bug 667313 - Current Tasks filter is broken at startup if Task View is active. r=philipp
authorMatthew Mecca <matthew.mecca@gmail.com>
Sun, 26 Jun 2011 11:45:00 +0200
changeset 7982 518c0fd4d729f688f24b1c6ece7492074737a1ea
parent 7981 deefec7bd03ca280cbdc0066b1b64502d3e563e4
child 7983 5566a7cb0d933c225a3d960b1ed544d1e2588cea
push id50
push usermozilla@kewis.ch
push dateTue, 19 Jul 2011 20:04:29 +0000
treeherdercomm-beta@aee08b4d6cf3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs667313
Fix bug 667313 - Current Tasks filter is broken at startup if Task View is active. r=philipp
calendar/base/src/calFilter.js
--- a/calendar/base/src/calFilter.js
+++ b/calendar/base/src/calFilter.js
@@ -14,16 +14,17 @@
  * The Original Code is Mozilla Calendar code.
  * 
  * The Initial Developer of the Original Code is
  *   Fred Jendrzejewski <fred.jen@web.de>
  * Portions created by the Initial Developer are Copyright (C) 2008
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
+ *   Matthew Mecca <matthew.mecca@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -200,16 +201,17 @@ calFilter.prototype = {
  */
 
 function getDatesForFilter(aFilter) {
     let endDate = cal.createDateTime();
     let startDate = cal.createDateTime();
     let duration = cal.createDuration();
     let oneDay = cal.createDuration();
     oneDay.days = 1;
+    let selectedDate = currentView().selectedDay;
 
     let durFilterReg = /next|last\d+\D+$/
     if (durFilterReg.exec(aFilter)) {
         duration =  durationFromFilter(aFilter);
         if (!duration) {
             endDate = null;
             startDate = null;
         } else {
@@ -239,30 +241,29 @@ function getDatesForFilter(aFilter) {
             break;
 
         case "future":
             startDate = cal.now();
             endDate = null;
             break;
 
         case "current":
-            let selectedDate = currentView().selectedDay;
-            startDate = selectedDate.clone();
+            startDate = selectedDate ? selectedDate.clone() : cal.now();
             startDate.isDate = true;
             endDate = startDate.clone();
             endDate.addDuration(oneDay);
             break;
 
         case "throughcurrent":
         case "open":
         case "overdue":
         case "completed":
         case "notstarted":
             // use the later of the current date or the selected date of the current view
-            endDate = currentView().selectedDay.clone();
+            endDate = selectedDate ? selectedDate.clone() : cal.now();
             if (endDate.jsDate < cal.now().jsDate) {
                 endDate = cal.now();
             }
             endDate.isDate = true;
             endDate.addDuration(oneDay);
             break;
 
         default: