Require DB transaction in Zotero.Collection.prototype.removeItems()
For consistency with Zotero.Collection.prototype.addItems()
This commit is contained in:
parent
f98de97e4d
commit
7ede52355d
2 changed files with 24 additions and 19 deletions
|
@ -369,6 +369,7 @@ Zotero.Collection.prototype.addItem = function (itemID, options) {
|
||||||
/**
|
/**
|
||||||
* Add multiple items to the collection in batch
|
* Add multiple items to the collection in batch
|
||||||
*
|
*
|
||||||
|
* Requires a transaction
|
||||||
* Does not require a separate save()
|
* Does not require a separate save()
|
||||||
*
|
*
|
||||||
* @param {Number[]} itemIDs
|
* @param {Number[]} itemIDs
|
||||||
|
@ -403,6 +404,7 @@ Zotero.Collection.prototype.addItems = Zotero.Promise.coroutine(function* (itemI
|
||||||
/**
|
/**
|
||||||
* Remove a item from the collection. The item is not deleted from the library.
|
* Remove a item from the collection. The item is not deleted from the library.
|
||||||
*
|
*
|
||||||
|
* Requires a transaction
|
||||||
* Does not require a separate save()
|
* Does not require a separate save()
|
||||||
*
|
*
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
|
@ -425,7 +427,7 @@ Zotero.Collection.prototype.removeItems = Zotero.Promise.coroutine(function* (it
|
||||||
|
|
||||||
var current = this.getChildItems(true);
|
var current = this.getChildItems(true);
|
||||||
|
|
||||||
return Zotero.DB.executeTransaction(function* () {
|
Zotero.DB.requireTransaction();
|
||||||
for (let i=0; i<itemIDs.length; i++) {
|
for (let i=0; i<itemIDs.length; i++) {
|
||||||
let itemID = itemIDs[i];
|
let itemID = itemIDs[i];
|
||||||
|
|
||||||
|
@ -440,7 +442,6 @@ Zotero.Collection.prototype.removeItems = Zotero.Promise.coroutine(function* (it
|
||||||
skipDateModifiedUpdate: true
|
skipDateModifiedUpdate: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}.bind(this));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1883,13 +1883,15 @@ Zotero.ItemTreeView.prototype.deleteSelection = Zotero.Promise.coroutine(functio
|
||||||
collectionTreeRow.ref.deleteItems(ids);
|
collectionTreeRow.ref.deleteItems(ids);
|
||||||
}
|
}
|
||||||
else if (collectionTreeRow.isTrash() || collectionTreeRow.isPublications()) {
|
else if (collectionTreeRow.isTrash() || collectionTreeRow.isPublications()) {
|
||||||
Zotero.Items.erase(ids);
|
yield Zotero.Items.eraseTx(ids);
|
||||||
}
|
}
|
||||||
else if (collectionTreeRow.isLibrary(true) || force) {
|
else if (collectionTreeRow.isLibrary(true) || force) {
|
||||||
Zotero.Items.trashTx(ids);
|
yield Zotero.Items.trashTx(ids);
|
||||||
}
|
}
|
||||||
else if (collectionTreeRow.isCollection()) {
|
else if (collectionTreeRow.isCollection()) {
|
||||||
collectionTreeRow.ref.removeItems(ids);
|
yield Zotero.DB.executeTransaction(function* () {
|
||||||
|
yield collectionTreeRow.ref.removeItems(ids);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
//this._treebox.endUpdateBatch();
|
//this._treebox.endUpdateBatch();
|
||||||
});
|
});
|
||||||
|
@ -3047,7 +3049,9 @@ Zotero.ItemTreeView.prototype.drop = Zotero.Promise.coroutine(function* (row, or
|
||||||
throw new Error("Drag source must be a collection");
|
throw new Error("Drag source must be a collection");
|
||||||
}
|
}
|
||||||
if (collectionTreeRow.id != sourceCollectionTreeRow.id) {
|
if (collectionTreeRow.id != sourceCollectionTreeRow.id) {
|
||||||
|
yield Zotero.DB.executeTransaction(function* () {
|
||||||
yield collectionTreeRow.ref.removeItems(toMove);
|
yield collectionTreeRow.ref.removeItems(toMove);
|
||||||
|
}.bind(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue