зеркало из https://github.com/mozilla/pjs.git
Add method to calIItemBase to compare items by id, regardless of whether either or both are proxy items and change some code to use this new method (bug 328011). Thanks to <daniel.boelzle@sun.com> for the patch; r=dmose
This commit is contained in:
Родитель
3b928e3f9f
Коммит
941443d22d
|
@ -207,8 +207,7 @@
|
|||
<parameter name="aItem"/>
|
||||
<body><![CDATA[
|
||||
for each (ed in this.mItemData) {
|
||||
if (ed.item == aItem ||
|
||||
(ed.item.id == aItem.id && ed.item.recurrence_id == aItem.recurrence_id))
|
||||
if (aItem.sameId(ed.item))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -251,8 +250,7 @@
|
|||
var origLen = this.mItemData.length;
|
||||
this.mItemData = this.mItemData.filter(
|
||||
function(itd) {
|
||||
if (itd.item == aItem ||
|
||||
(itd.item.id == aItem.id && itd.item.recurrence_id == aItem.recurrence_id))
|
||||
if (aItem.sameId(itd.item))
|
||||
{
|
||||
deleted.push(itd);
|
||||
return false;
|
||||
|
|
|
@ -78,6 +78,16 @@ interface calIItemBase : nsISupports
|
|||
// clone always returns a mutable event
|
||||
calIItemBase clone();
|
||||
|
||||
/**
|
||||
* Checks whether the argument object refers the same calendar item as
|
||||
* this one, by testing both the id and recurrenceId property. This
|
||||
*
|
||||
* @arg aItem the item to compare against this one
|
||||
*
|
||||
* @return true if both ids match, false otherwise
|
||||
*/
|
||||
boolean hasSameIds(in calIItemBase aItem);
|
||||
|
||||
//
|
||||
// the generation number of this item; 0 means
|
||||
// that it's never been stored in a store
|
||||
|
|
|
@ -157,6 +157,13 @@ calItemBase.prototype = {
|
|||
this.mImmutable = true;
|
||||
},
|
||||
|
||||
hasSameIds: function(that) {
|
||||
return (that && this.id == that.id &&
|
||||
(this.recurrenceId == that.recurrenceId || // both null
|
||||
(this.recurrenceId && that.recurrenceId &&
|
||||
this.recurrenceId.compare(that.recurrenceId) == 0)));
|
||||
},
|
||||
|
||||
// initialize this class's members
|
||||
initItemBase: function () {
|
||||
var now = new Date();
|
||||
|
|
Загрузка…
Ссылка в новой задаче