Bug 396277, Bug 396279 - fixing view update after timezone, tasks in view change; r=mickey

This commit is contained in:
daniel.boelzle%sun.com 2007-09-17 09:14:59 +00:00
Родитель 376f6f672a
Коммит a7fdbd54de
5 изменённых файлов: 81 добавлений и 89 удалений

Просмотреть файл

@ -1091,24 +1091,17 @@
<parameter name="aEndDate"/>
<body><![CDATA[
if (this.mTimezone != aStartDate.timezone) {
aStartDate = aStartDate.getInTimezone(this.mTimezone);
aEndDate = aEndDate.getInTimezone(this.mTimezone);
aStartDate = aStartDate.getInTimezone(this.mTimezone);
aEndDate = aEndDate.getInTimezone(this.mTimezone);
}
var startDate = aStartDate.startOfWeek.clone();
var endDate = aEndDate.endOfWeek.clone();
startDate.day += this.mWeekStartOffset;
endDate.day += this.mWeekStartOffset;
function compareDatetimes(one, two) {
return ((!one && !two) ||
(one && two && (one.compare(two) == 0)));
}
if (!compareDatetimes(this.mStartDate, startDate) ||
!compareDatetimes(this.mEndDate, endDate)) {
this.mStartDate = startDate;
this.mEndDate = endDate;
this.refresh();
}
this.mStartDate = aStartDate.startOfWeek;
this.mEndDate = aEndDate.endOfWeek;
this.mStartDate.day += this.mWeekStartOffset;
this.mEndDate.day += this.mWeekStartOffset;
this.refresh();
]]></body>
</method>
@ -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;
}
]]></body>
</method>

Просмотреть файл

@ -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);
}
]]></body>
</method>
@ -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();
]]></body>
</method>
@ -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;
}
]]></body>
</method>

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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 );