From c73e6643123c7cd6f319433ca5d0597f163b58c7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 16 Dec 2018 02:20:31 -0500 Subject: [PATCH] Fix logged error when dragging collection to another library "Collection ID '1234' is not an integer (string)" --- .../content/zotero/xpcom/collectionTreeView.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index e01de969d0..888abf134f 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -2056,8 +2056,10 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r } // Mark copied item for adding to collection if (parentID) { - if (!addItems[parentID]) { - addItems[parentID] = []; + let parentItems = addItems.get(parentID); + if (!parentItems) { + parentItems = []; + addItems.set(parentID, parentItems); } // If source item is a top-level non-regular item (which can exist in a @@ -2071,7 +2073,7 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r } } - addItems[parentID].push(id); + parentItems.push(id); } } } @@ -2083,11 +2085,11 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r type: 'collection' }]; - var addItems = {}; + var addItems = new Map(); yield copyCollections(collections, targetCollectionID, addItems); - for (var collectionID in addItems) { - var collection = yield Zotero.Collections.getAsync(collectionID); - yield collection.addItems(addItems[collectionID]); + for (let [collectionID, items] of addItems.entries()) { + let collection = yield Zotero.Collections.getAsync(collectionID); + yield collection.addItems(items); } // TODO: add subcollections and subitems, if they don't already exist,