Fix item duplication
This commit is contained in:
parent
828f3f5024
commit
bb3496dfa8
|
@ -3737,6 +3737,7 @@ Zotero.Item.prototype.multiDiff = Zotero.Promise.coroutine(function* (otherItems
|
||||||
*
|
*
|
||||||
* @param {Number} [libraryID] - libraryID of the new item, or the same as original if omitted
|
* @param {Number} [libraryID] - libraryID of the new item, or the same as original if omitted
|
||||||
* @param {Boolean} [skipTags=false] - Skip tags
|
* @param {Boolean} [skipTags=false] - Skip tags
|
||||||
|
* @return {Promise<Zotero.Item>}
|
||||||
*/
|
*/
|
||||||
Zotero.Item.prototype.clone = Zotero.Promise.coroutine(function* (libraryID, skipTags) {
|
Zotero.Item.prototype.clone = Zotero.Promise.coroutine(function* (libraryID, skipTags) {
|
||||||
Zotero.debug('Cloning item ' + this.id);
|
Zotero.debug('Cloning item ' + this.id);
|
||||||
|
|
|
@ -1548,19 +1548,12 @@ var ZoteroPane = new function()
|
||||||
var item = self.getSelectedItems()[0];
|
var item = self.getSelectedItems()[0];
|
||||||
var newItem;
|
var newItem;
|
||||||
|
|
||||||
yield Zotero.DB.executeTransaction(function () {
|
yield Zotero.DB.executeTransaction(function* () {
|
||||||
// Create new unsaved clone item in target library
|
newItem = yield item.clone(null, !Zotero.Prefs.get('groups.copyTags'));
|
||||||
newItem = new Zotero.Item(item.itemTypeID);
|
|
||||||
newItem.libraryID = item.libraryID;
|
|
||||||
// DEBUG: save here because clone() doesn't currently work on unsaved tagged items
|
|
||||||
var id = yield newItem.save();
|
|
||||||
|
|
||||||
var newItem = yield Zotero.Items.getAsync(id);
|
|
||||||
yield item.clone(false, newItem, false, !Zotero.Prefs.get('groups.copyTags'));
|
|
||||||
yield newItem.save();
|
yield newItem.save();
|
||||||
|
|
||||||
if (self.collectionsView.selectedTreeRow.isCollection() && newItem.isTopLevelItem()) {
|
if (self.collectionsView.selectedTreeRow.isCollection() && newItem.isTopLevelItem()) {
|
||||||
self.collectionsView.selectedTreeRow.ref.addItem(newItem.id);
|
yield self.collectionsView.selectedTreeRow.ref.addItem(newItem.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user