Skip to content

Instantly share code, notes, and snippets.

@creativepsyco
Created May 18, 2011 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativepsyco/979830 to your computer and use it in GitHub Desktop.
Save creativepsyco/979830 to your computer and use it in GitHub Desktop.
Modified delete function in calCachedCalendar.js
deleteItem: function(item, listener) {
/*if (this.offline) {
//ASSERT(false, "unexpected!");
if (listener) {
listener.onOperationComplete(this, Components.interfaces.calIErrors.CAL_IS_READONLY,
Components.interfaces.calIOperation.DELETE, null, null);
}
return null;
}*/
// Forwarding add/modify/delete to the cached calendar using the calIObserver
// callbacks would be advantageous, because the uncached provider could implement
// a true push mechanism firing without being triggered from within the program.
// But this would mean the uncached provider fires on the passed
// calIOperationListener, e.g. *before* it fires on calIObservers
// (because that order is undefined). Firing onOperationComplete before onAddItem et al
// would result in this facade firing onOperationComplete even though the modification
// hasn't yet been performed on the cached calendar (which happens in onAddItem et al).
// Result is that we currently stick to firing onOperationComplete if the cached calendar
// has performed the modification, see below:
var this_ = this;
var opListener = {
onGetResult: function(calendar, status, itemType, detail, count, items) {
ASSERT(false, "unexpected!");
},
onOperationComplete: function(calendar, status, opType, id, detail) {
if (Components.isSuccessCode(status)) {
this_.mCachedCalendar.deleteItem(item, listener);
} else if (listener) {
listener.onOperationComplete(this_, status, opType, id, detail);
}
}
}
return this.mCachedCalendar.deleteItem(item, opListener);
//return this.mUncachedCalendar.deleteItem(item, opListener);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment