www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit f3ceb7f66e0caa2e46448e92323c2390b13e855c
parent ab2bedc0dff63dfd721f2df03f7a48d22c16c4b1
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 19 Apr 2017 04:24:34 -0400

Load object data when looking up integration items

Item data may not have been loaded for a library when requesting an item
from a document (e.g., for Refresh), so we need to load all data for
requested items to avoid unloaded-data errors. (Data isn't loaded if
it's already been loaded, so hopefully this doesn't slow things down too
much.)

Diffstat:
Mchrome/content/zotero/xpcom/integration.js | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js @@ -2386,6 +2386,8 @@ Zotero.Integration.Session.prototype.addCitation = Zotero.Promise.coroutine(func * Throws a MissingItemException if item was not found. */ Zotero.Integration.Session.prototype.lookupItems = Zotero.Promise.coroutine(function* (citation, index) { + let items = []; + for(var i=0, n=citation.citationItems.length; i<n; i++) { var citationItem = citation.citationItems[i]; @@ -2477,9 +2479,17 @@ Zotero.Integration.Session.prototype.lookupItems = Zotero.Promise.coroutine(func } if(zoteroItem) { + items.push(zoteroItem); citationItem.id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id; } } + + // Items may be in libraries that haven't been loaded, and retrieveItem() is synchronous, so load + // all data (as required by toJSON(), which is used by itemToExportFormat(), which is used by + // itemToCSLJSON()) now + if (items.length) { + yield Zotero.Items.loadDataTypes(items); + } }); /**