Skip to content

Commit

Permalink
Make a missing related item not fatal
Browse files Browse the repository at this point in the history
Since item relations are synced with individual items, an item can exist
before the item it's related to has been downloaded.
  • Loading branch information
dstillman committed May 19, 2017
1 parent fc4eb53 commit 1cbc244
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion chrome/content/zotero/bindings/relatedbox.xml
Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -194,7 +204,7 @@
}
rows.appendChild(row);
}
this.updateCount(relatedKeys.length);
this.updateCount(rows.childNodes.length);
}
]]></body>
</method>
Expand Down

0 comments on commit 1cbc244

Please sign in to comment.