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.)
This commit is contained in:
Dan Stillman 2017-04-19 04:24:34 -04:00
parent ab2bedc0df
commit f3ceb7f66e

View file

@ -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);
}
});
/**