diff --git a/calendar/base/content/calendar-month-view.xml b/calendar/base/content/calendar-month-view.xml index 2105e9023ad..3779e038f2b 100644 --- a/calendar/base/content/calendar-month-view.xml +++ b/calendar/base/content/calendar-month-view.xml @@ -1091,24 +1091,17 @@ @@ -1208,13 +1201,14 @@ else filter |= this.mCalendar.ITEM_FILTER_TYPE_EVENT; - this.mRefreshPending = this.mCalendar.getItems(filter, - 0, - this.startDate, - this.queryEndDate, - this.mOperationListener); - if (!this.mRefreshPending) { // no support for calIOperation, fallback to bool - this.mRefreshPending = true; + this.mRefreshPending = true; + pendingRefresh = this.mCalendar.getItems(filter, + 0, + this.startDate, + this.queryEndDate, + this.mOperationListener); + if (pendingRefresh && pendingRefresh.isPending) { // support for calIOperation + this.mRefreshPending = pendingRefresh; } ]]> diff --git a/calendar/base/content/calendar-multiday-view.xml b/calendar/base/content/calendar-multiday-view.xml index 1a157291466..39d721da384 100644 --- a/calendar/base/content/calendar-multiday-view.xml +++ b/calendar/base/content/calendar-multiday-view.xml @@ -2554,36 +2554,29 @@ aStartDate = aEndDate = null; if (this.mDisplayDaysOff) { - function compareDatetimes(one, two) { - return ((!one && !two) || - (one && two && (one.compare(two) == 0))); - } - if (!compareDatetimes(this.mStartDate, startDate) || - !compareDatetimes(this.mEndDate, endDate)) { - startDate.makeImmutable(); - endDate.makeImmutable(); - this.mDateList = null; - this.mStartDate = startDate; - this.mEndDate = endDate; - // - // For a true multiday view (e.g, 3 days advanced by one day - // at a time), a smarter refresh could reuse boxes, comparing - // the current date range and add/remove, instead of just - // replacing. - // - this.refresh(); - } + startDate.makeImmutable(); + endDate.makeImmutable(); + this.mDateList = null; + this.mStartDate = startDate; + this.mEndDate = endDate; + // + // For a true multiday view (e.g, 3 days advanced by one day + // at a time), a smarter refresh could reuse boxes, comparing + // the current date range and add/remove, instead of just + // replacing. + // + this.refresh(); } else { // workdays only - var dateList = new Array(); - for (var d = startDate.clone(); d.compare(endDate) <= 0;) { - if (this.mDaysOffArray.indexOf(d.weekday) == -1) { - var workday = d.clone(); - workday.makeImmutable(); - dateList.push(workday); - } - d.day += 1; + var dateList = new Array(); + for (var d = startDate.clone(); d.compare(endDate) <= 0;) { + if (this.mDaysOffArray.indexOf(d.weekday) == -1) { + var workday = d.clone(); + workday.makeImmutable(); + dateList.push(workday); } - this.setDateList(dateList.length, dateList); + d.day += 1; + } + this.setDateList(dateList.length, dateList); } ]]> @@ -2595,10 +2588,11 @@ this.mStartDate = null; this.mEndDate = null; - var dateList = null; - if (aCount > 0) { + if (aCount == 0) { + this.mDateList = null; + } else { aDates.sort (function(a, b) { return a.compare(b); }); - dateList = aDates.map( + this.mDateList = aDates.map( function dateMapper(d) { if (d.isDate && !d.isMutable) return d; @@ -2610,14 +2604,8 @@ } ); } - function compareDatetimes(one, two) { - return ((!one && !two) || - (one && two && (one.compare(two) == 0))); - } - if (!compareArrays(this.mDateList, dateList, compareDatetimes)) { - this.mDateList = dateList; - this.refresh(); - } + + this.refresh(); ]]> @@ -2903,13 +2891,14 @@ else filter |= this.mCalendar.ITEM_FILTER_TYPE_EVENT; - this.mRefreshPending = this.mCalendar.getItems(filter, - 0, - this.startDate, - this.queryEndDate, - this.mOperationListener); - if (!this.mRefreshPending) { // no support for calIOperation, fallback to bool - this.mRefreshPending = true; + this.mRefreshPending = true; + pendingRefresh = this.mCalendar.getItems(filter, + 0, + this.startDate, + this.queryEndDate, + this.mOperationListener); + if (pendingRefresh && pendingRefresh.isPending) { // support for calIOperation + this.mRefreshPending = pendingRefresh; } ]]> diff --git a/calendar/base/content/calendar-unifinder-todo.js b/calendar/base/content/calendar-unifinder-todo.js index c4f38128299..e3404cd039f 100644 --- a/calendar/base/content/calendar-unifinder-todo.js +++ b/calendar/base/content/calendar-unifinder-todo.js @@ -200,11 +200,13 @@ function toDoUnifinderRefresh() ccalendar.getItems(filter, 0, null, null, refreshListener); var deck = document.getElementById("view-deck"); + var selectedShowCompleted = deck.selectedPanel.showCompleted; for each (view in deck.childNodes) { view.showCompleted = !hideCompleted; } var selectedDay = deck.selectedPanel.selectedDay; - if (selectedDay) { + // only update view if hide completed has actually changed: + if ((deck.selectedPanel.showCompleted != selectedShowCompleted) && selectedDay) { deck.selectedPanel.goToDay(selectedDay); } } diff --git a/calendar/base/src/calUtils.js b/calendar/base/src/calUtils.js index 21a8928d85a..6591b209353 100644 --- a/calendar/base/src/calUtils.js +++ b/calendar/base/src/calUtils.js @@ -1203,6 +1203,7 @@ var gOpGroupId = 0; * calendar operations (without handle). */ function calOperationGroup(cancelFunc) { + this.wrappedJSObject = this; if (!gOpGroupPrefix) { gOpGroupPrefix = (getUUID() + "-"); } @@ -1244,6 +1245,10 @@ calOperationGroup.prototype = { } }, + toString: function calOperationGroup_toString() { + return ("[calOperationGroup] id=" + this.id); + }, + // calIOperation: get id() { return this.mId; @@ -1258,7 +1263,7 @@ calOperationGroup.prototype = { }, get success() { - return (!this.isPending && Components.results.isSuccessCode(this.status)); + return (!this.isPending && Components.isSuccessCode(this.status)); }, cancel: function calOperationGroup_cancel(status) { diff --git a/calendar/providers/composite/calCompositeCalendar.js b/calendar/providers/composite/calCompositeCalendar.js index c663500d977..5ae74355ddc 100644 --- a/calendar/providers/composite/calCompositeCalendar.js +++ b/calendar/providers/composite/calCompositeCalendar.js @@ -44,10 +44,11 @@ const calIOperationListener = Components.interfaces.calIOperationListener; function calCompositeCalendarObserverHelper (compCalendar) { this.compCalendar = compCalendar; + this.pendingLoads = {}; } calCompositeCalendarObserverHelper.prototype = { - suppressOnLoad: false, + pendingLoads: null, onStartBatch: function() { this.compCalendar.mObservers.notify("onStartBatch"); @@ -58,7 +59,11 @@ calCompositeCalendarObserverHelper.prototype = { }, onLoad: function(calendar) { - if (!this.suppressOnLoad) { + // avoid unnecessary onLoad events: + if (this.pendingLoads[calendar.id]) { + // don't forward if caused by composite: + delete this.pendingLoads[calendar.id]; + } else { // any refreshed dependent calendar logically refreshes // this composite calendar, thus we send out an onLoad // for this composite calendar: @@ -310,25 +315,22 @@ calCompositeCalendar.prototype = { }, refresh: function() { - this.mObserverHelper.suppressOnLoad = true; - try { - for each (cal in this.mCalendars) { - try { - if (cal.canRefresh) { - cal.refresh(); - } - } catch (e) { - ASSERT(false, e); + for each (cal in this.mCalendars) { + try { + if (cal.canRefresh) { + this.mObserverHelper.pendingLoads[cal.id] = true; + cal.refresh(); } + } catch (e) { + ASSERT(false, e); + delete this.mObserverHelper.pendingLoads[cal.id]; } - } finally { - this.mObserverHelper.suppressOnLoad = false; - // send out a single onLoad for this composite calendar, - // although e.g. the ics provider will trigger another - // onLoad asynchronously; we cannot rely on every calendar - // sending an onLoad: - this.mObservers.notify("onLoad", [this]); } + // send out a single onLoad for this composite calendar, + // although e.g. the ics provider will trigger another + // onLoad asynchronously; we cannot rely on every calendar + // sending an onLoad: + this.mObservers.notify("onLoad", [this]); }, // void modifyItem( in calIItemBase aNewItem, in calIItemBase aOldItem, in calIOperationListener aListener );