commit 0238a2c13c752b1c0b0ea4ef4c5a7cfac1455c2d
parent 74fe2a2bdc470f0b625f356dcc8161bd676592a2
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 23 Jun 2016 04:17:33 -0400
Fix errors citing items in unloaded libraries
Diffstat:
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js
@@ -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();
diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js
@@ -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) {