From 1f8b6fad61bc8ea0eb2e27146710d5b0d5897d5a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 13 May 2015 10:26:21 -0400 Subject: [PATCH] Don't include collections in child item JSON export But handle it in Zotero.Items.diff() if it's there for one item --- chrome/content/zotero/xpcom/data/dataObjects.js | 2 ++ chrome/content/zotero/xpcom/data/item.js | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 147e9d73a0..4a0f75f449 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -530,6 +530,8 @@ Zotero.DataObjects.prototype._diffCreators = function (data1, data2) { } Zotero.DataObjects.prototype._diffCollections = function (data1, data2) { + // Child items shouldn't have collections properties, but just in case one does + if (!data2) return false; if (data1.length != data2.length) return false; let c1 = data1.concat(); let c2 = data2.concat(); diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 2b8c4a2161..648cb3b0a4 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -4216,10 +4216,12 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options) { } // Collections - yield this.loadCollections(); - obj.collections = this.getCollections().map(function (id) { - return this.ContainerObjectsClass.getLibraryAndKeyFromID(id).key; - }.bind(this)); + if (this.isTopLevelItem()) { + yield this.loadCollections(); + obj.collections = this.getCollections().map(function (id) { + return this.ContainerObjectsClass.getLibraryAndKeyFromID(id).key; + }.bind(this)); + } // Relations yield this.loadRelations();