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.
This commit is contained in:
parent
fc4eb5308f
commit
1cbc2440ec
1 changed files with 11 additions and 1 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue