- 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)
This commit is contained in:
Dan Stillman 2011-06-01 14:28:59 +00:00
parent c7a44a6f37
commit 09e22e1e5d
3 changed files with 46 additions and 46 deletions

View file

@ -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.History.commit();
Zotero.DB.commitTransaction(); Zotero.DB.commitTransaction();
} }
@ -2011,47 +2050,8 @@ Zotero.Item.prototype.save = function() {
throw(e); throw(e);
} }
if (!this.id) { // New items have to be reloaded via Zotero.Items.get(),
this._id = itemID; // so mark them as disabled
}
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;
if (isNew) { if (isNew) {
var id = this.id; var id = this.id;
this._disabled = true; this._disabled = true;

View file

@ -471,11 +471,7 @@ var Zotero = new function(){
// Add notifier queue callbacks to the DB layer // Add notifier queue callbacks to the DB layer
Zotero.DB.addCallback('begin', Zotero.Notifier.begin); Zotero.DB.addCallback('begin', Zotero.Notifier.begin);
Zotero.DB.addCallback('commit', function () { Zotero.DB.addCallback('commit', Zotero.Notifier.commit);
setTimeout(function () {
Zotero.Notifier.commit();
}, 1)
});
Zotero.DB.addCallback('rollback', Zotero.Notifier.reset); Zotero.DB.addCallback('rollback', Zotero.Notifier.reset);
Zotero.Fulltext.init(); Zotero.Fulltext.init();

View file

@ -661,6 +661,8 @@ var ZoteroPane = new function()
var itemGroup = null; var itemGroup = null;
} }
Zotero.DB.beginTransaction();
var item = new Zotero.Item(typeID); var item = new Zotero.Item(typeID);
item.libraryID = libraryID; item.libraryID = libraryID;
for (var i in data) { for (var i in data) {
@ -672,6 +674,8 @@ var ZoteroPane = new function()
itemGroup.ref.addItem(itemID); itemGroup.ref.addItem(itemID);
} }
Zotero.DB.commitTransaction();
//set to Info tab //set to Info tab
document.getElementById('zotero-view-item').selectedIndex = 0; document.getElementById('zotero-view-item').selectedIndex = 0;