Fix error when purging tags that have already been erased

This commit is contained in:
Dan Stillman 2008-10-24 23:03:53 +00:00
parent 56eb416e3e
commit 4f2bcb15d5
2 changed files with 7 additions and 9 deletions

View file

@ -443,7 +443,7 @@ Zotero.Tag.prototype.serialize = function () {
/**
* Remove tag from all linked items
*
* Tags.erase() should be used externally instead of this
* Tags.erase() should be used instead of tag.erase() for deleting multiple tags
*
* Actual deletion of tag occurs in Zotero.Tags.purge()
*/
@ -484,6 +484,9 @@ Zotero.Tag.prototype.erase = function () {
itemTags.push(itemID + '-' + this.id);
}
this.unload(this.id);
Zotero.Notifier.trigger('remove', 'item-tag', itemTags);
// Send notification of linked items

View file

@ -315,19 +315,13 @@ Zotero.Tags = new function() {
function erase(ids) {
ids = Zotero.flattenArguments(ids);
var erasedTags = {};
Zotero.DB.beginTransaction();
for each(var id in ids) {
var tag = this.get(id);
if (tag) {
erasedTags[id] = tag.serialize();
tag.erase();
}
}
this.unload(ids);
Zotero.DB.commitTransaction();
}
@ -364,8 +358,9 @@ Zotero.Tags = new function() {
for each(var tagID in toDelete) {
var tag = Zotero.Tags.get(tagID);
Zotero.debug(tag);
notifierData[tagID] = { old: tag.serialize() }
if (tag) {
notifierData[tagID] = { old: tag.serialize() }
}
}
this.unload(toDelete);