diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 499777905..66eb19198 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2000,6 +2000,45 @@ Zotero.Item.prototype.save = function() { } } + if (!this.id) { + this._id = itemID; + } + + if (!this.key) { + this._key = key; + } + + 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); + } + } + + Zotero.Items.reload(this.id); + //Zotero.History.commit(); Zotero.DB.commitTransaction(); } @@ -2011,47 +2050,8 @@ Zotero.Item.prototype.save = function() { throw(e); } - if (!this.id) { - this._id = itemID; - } - - if (!this.key) { - this._key = key; - } - - 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); - } - } - - Zotero.Items.reload(this.id); - - this._previousData = null; - + // New items have to be reloaded via Zotero.Items.get(), + // so mark them as disabled if (isNew) { var id = this.id; this._disabled = true; diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 254c905cb..1008c3281 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -471,11 +471,7 @@ var Zotero = new function(){ // Add notifier queue callbacks to the DB layer Zotero.DB.addCallback('begin', Zotero.Notifier.begin); - Zotero.DB.addCallback('commit', function () { - setTimeout(function () { - Zotero.Notifier.commit(); - }, 1) - }); + Zotero.DB.addCallback('commit', Zotero.Notifier.commit); Zotero.DB.addCallback('rollback', Zotero.Notifier.reset); Zotero.Fulltext.init(); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index a7b1ac9f0..8e8093ef1 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -661,6 +661,8 @@ var ZoteroPane = new function() var itemGroup = null; } + Zotero.DB.beginTransaction(); + var item = new Zotero.Item(typeID); item.libraryID = libraryID; for (var i in data) { @@ -672,6 +674,8 @@ var ZoteroPane = new function() itemGroup.ref.addItem(itemID); } + Zotero.DB.commitTransaction(); + //set to Info tab document.getElementById('zotero-view-item').selectedIndex = 0;