From 704e8ffeea7555499fe7a09d4edd84bf86e54fd9 Mon Sep 17 00:00:00 2001
From: Dan Stillman <dstillman@zotero.org>
Date: Sat, 4 Mar 2017 04:17:25 -0500
Subject: [PATCH] Fix dragging collections between libraries

---
 chrome/content/zotero/xpcom/collectionTreeView.js | 8 ++++----
 chrome/content/zotero/xpcom/uri.js                | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js
index 9c9b6e7ffe..e3c0bb970b 100644
--- a/chrome/content/zotero/xpcom/collectionTreeView.js
+++ b/chrome/content/zotero/xpcom/collectionTreeView.js
@@ -1811,11 +1811,11 @@ Zotero.CollectionTreeView.prototype.canDropCheckAsync = Zotero.Promise.coroutine
 			// Dragging a collection to a different library
 			if (treeRow.ref.libraryID != draggedCollection.libraryID) {
 				// Disallow if linked collection already exists
-				if (yield col.getLinkedCollection(treeRow.ref.libraryID)) {
+				if (yield draggedCollection.getLinkedCollection(treeRow.ref.libraryID)) {
 					return false;
 				}
 				
-				var descendents = col.getDescendents(false, 'collection');
+				let descendents = draggedCollection.getDescendents(false, 'collection');
 				for (let descendent of descendents) {
 					descendent = Zotero.Collections.get(descendent.id);
 					// Disallow if linked collection already exists for any subcollections
@@ -2023,14 +2023,14 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
 							
 							var newCollection = new Zotero.Collection;
 							newCollection.libraryID = targetLibraryID;
-							yield c.clone(false, newCollection);
+							c.clone(false, newCollection);
 							if (parentID) {
 								newCollection.parentID = parentID;
 							}
 							var collectionID = yield newCollection.save();
 							
 							// Record link
-							c.addLinkedCollection(newCollection);
+							yield c.addLinkedCollection(newCollection);
 							
 							// Recursively copy subcollections
 							if (desc.children.length) {
diff --git a/chrome/content/zotero/xpcom/uri.js b/chrome/content/zotero/xpcom/uri.js
index 67ef5de7e3..a430dd2bf6 100644
--- a/chrome/content/zotero/xpcom/uri.js
+++ b/chrome/content/zotero/xpcom/uri.js
@@ -173,7 +173,7 @@ Zotero.URI = new function () {
 	 * Return URI of collection, which might be a local URI if user hasn't synced
 	 */
 	this.getCollectionURI = function (collection) {
-		return this._getObjectURI(item);
+		return this._getObjectURI(collection);
 	}