www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit e636fe0f65e81473fd3f3acd50a69a5108bb6e8e
parent 2bfb5af2055d44dd336944abf66a00a3151e8750
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri,  3 Jul 2009 08:40:29 +0000

Fixes #1444, Attachment arrow/count persists after delete

This was fixed but then broken again for trashed items. Now fixed again.


Diffstat:
Mchrome/content/zotero/xpcom/data/item.js | 32++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -1909,6 +1909,28 @@ Zotero.Item.prototype.save = function() { } if (this._changedDeleted) { + // Update child item counts on parent + var sourceItemID = this.getSource(); + if (sourceItemID) { + var sourceItem = Zotero.Items.get(sourceItemID); + if (this._deleted) { + if (this.isAttachment()) { + sourceItem.decrementAttachmentCount(); + } + else { + sourceItem.decrementNoteCount(); + } + } + else { + if (this.isAttachment()) { + sourceItem.incrementAttachmentCount(); + } + else { + sourceItem.incrementNoteCount(); + } + } + } + // Refresh trash Zotero.Notifier.trigger('refresh', 'collection', 0); if (this._deleted) { Zotero.Notifier.trigger('trash', 'item', this.id); @@ -2342,13 +2364,11 @@ Zotero.Item.prototype.getNotes = function(includeTrashed) { // /////////////////////////////////////////////////////// Zotero.Item.prototype.incrementAttachmentCount = function() { - Zotero.debug('incrementing attachment count from ' + this._numAttachments); this._numAttachments++; } Zotero.Item.prototype.decrementAttachmentCount = function() { - Zotero.debug('decrementing attachment count from ' + this._numAttachments); this._numAttachments--; } @@ -3568,7 +3588,9 @@ Zotero.Item.prototype.erase = function(deleteChildren) { if (sourceItemID) { var sourceItem = Zotero.Items.get(sourceItemID); changedItemsNotifierData[sourceItem.id] = { old: sourceItem.serialize() }; - sourceItem.decrementNoteCount(); + if (!this.deleted) { + sourceItem.decrementNoteCount(); + } changedItems.push(sourceItemID); } } @@ -3580,7 +3602,9 @@ Zotero.Item.prototype.erase = function(deleteChildren) { if (sourceItemID) { var sourceItem = Zotero.Items.get(sourceItemID); changedItemsNotifierData[sourceItem.id] = { old: sourceItem.serialize() }; - sourceItem.decrementAttachmentCount(); + if (!this.deleted) { + sourceItem.decrementAttachmentCount(); + } changedItems.push(sourceItemID); }