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:
parent
ab2bedc0df
commit
f3ceb7f66e
|
@ -2386,6 +2386,8 @@ Zotero.Integration.Session.prototype.addCitation = Zotero.Promise.coroutine(func
|
||||||
* Throws a MissingItemException if item was not found.
|
* Throws a MissingItemException if item was not found.
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Session.prototype.lookupItems = Zotero.Promise.coroutine(function* (citation, index) {
|
Zotero.Integration.Session.prototype.lookupItems = Zotero.Promise.coroutine(function* (citation, index) {
|
||||||
|
let items = [];
|
||||||
|
|
||||||
for(var i=0, n=citation.citationItems.length; i<n; i++) {
|
for(var i=0, n=citation.citationItems.length; i<n; i++) {
|
||||||
var citationItem = citation.citationItems[i];
|
var citationItem = citation.citationItems[i];
|
||||||
|
|
||||||
|
@ -2477,9 +2479,17 @@ Zotero.Integration.Session.prototype.lookupItems = Zotero.Promise.coroutine(func
|
||||||
}
|
}
|
||||||
|
|
||||||
if(zoteroItem) {
|
if(zoteroItem) {
|
||||||
|
items.push(zoteroItem);
|
||||||
citationItem.id = zoteroItem.cslItemID ? zoteroItem.cslItemID : zoteroItem.id;
|
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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user