mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 11:28:38 +00:00
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:
parent
6b1a8e840d
commit
08e541e3ee
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user