commit 1cbc2440ec45ac085f2fad51443cada58a6cab98
parent fc4eb5308fb242152348d9d98bcc9301cae066fe
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 19 May 2017 11:21:33 -0400
Make a missing related item not fatal
Since item relations are synced with individual items, an item can exist
before the item it's related to has been downloaded.
Diffstat:
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/bindings/relatedbox.xml b/chrome/content/zotero/bindings/relatedbox.xml
@@ -81,6 +81,11 @@
if (keys.length) {
for (let key of keys) {
let item = Zotero.Items.getByLibraryAndKey(this.item.libraryID, key);
+ if (!item) {
+ Zotero.debug(`Related item ${this.item.libraryID}/${key} not found `
+ + `for item ${this.item.libraryKey}`, 2);
+ continue;
+ }
r = r + item.getDisplayTitle() + ", ";
}
r = r.substr(0,r.length-2);
@@ -139,6 +144,11 @@
let relatedItem = Zotero.Items.getByLibraryAndKey(
this.item.libraryID, key
);
+ if (!relatedItem) {
+ Zotero.debug(`Related item ${this.item.libraryID}/${key} not found `
+ + `for item ${this.item.libraryKey}`, 2);
+ continue;
+ }
let id = relatedItem.id;
let icon = document.createElement("image");
icon.className = "zotero-box-icon";
@@ -194,7 +204,7 @@
}
rows.appendChild(row);
}
- this.updateCount(relatedKeys.length);
+ this.updateCount(rows.childNodes.length);
}
]]></body>
</method>