Fix errors citing items in unloaded libraries

This commit is contained in:
Dan Stillman 2016-06-23 04:17:33 -04:00
parent 74fe2a2bdc
commit 0238a2c13c
2 changed files with 14 additions and 2 deletions

View File

@ -418,7 +418,16 @@ var Zotero_QuickFormat = new function () {
// Search results might be in an unloaded library, so get items asynchronously and load
// necessary data
var items = yield Zotero.Items.getAsync(searchResultIDs);
yield Zotero.Items.loadDataTypes(items, ['itemData', 'creators']);
yield Zotero.Items.loadDataTypes(items);
// Load child items of search matches
// TODO: exclude child items from itemToExportFormat() so this isn't necessary?
for (let item of items) {
let ids = item.getAttachments().concat(item.getNotes());
if (ids.length) {
let childItems = yield Zotero.Items.getAsync(ids);
yield Zotero.Items.loadDataTypes(childItems)
}
}
searchString = searchString.toLowerCase();
var collation = Zotero.getLocaleCollation();

View File

@ -393,10 +393,13 @@ Zotero.DataObjects.prototype.getObjectVersions = Zotero.Promise.coroutine(functi
* results might include objects in libraries that haven't yet been loaded.
*
* @param {Zotero.DataObject[]} objects
* @param {String[]} dataTypes
* @param {String[]} [dataTypes] - Data types to load, defaulting to all types
* @return {Promise}
*/
Zotero.DataObjects.prototype.loadDataTypes = Zotero.Promise.coroutine(function* (objects, dataTypes) {
if (!dataTypes) {
dataTypes = this.ObjectClass.prototype._dataTypes;
}
for (let dataType of dataTypes) {
let typeIDsByLibrary = {};
for (let obj of objects) {