commit 09e22e1e5db4ceaf0a5e3235371e1e570eb2e2fb
parent c7a44a6f37ec4cfe1065a7d49b35604e78cf685e
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 1 Jun 2011 14:28:59 +0000
- Revert async notifier change in r9341
- Better fix for excessive item saving activity
- Fix for erroneous switch to library after adding an item to a collection (since r9341)
Diffstat:
3 files changed, 46 insertions(+), 46 deletions(-)
diff --git 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
@@ -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
@@ -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;