Clarify variable name in Item#_updateAttachmentStates()

This commit is contained in:
Dan Stillman 2025-08-22 02:56:43 -04:00
parent ea3f14f195
commit 2216729721

View file

@ -2824,7 +2824,7 @@ Zotero.Item.prototype._updateAttachmentStates = function (exists) {
}
try {
var item = this.ObjectsClass.getByLibraryAndKey(this.libraryID, parentKey);
var parentItem = this.ObjectsClass.getByLibraryAndKey(this.libraryID, parentKey);
}
catch (e) {
if (e instanceof Zotero.Exception.UnloadedDataException) {
@ -2834,16 +2834,18 @@ Zotero.Item.prototype._updateAttachmentStates = function (exists) {
}
throw e;
}
if (!item) {
if (!parentItem) {
Zotero.logError(`Attachment parent ${this.libraryID}/${parentKey} doesn't exist`);
return;
}
if (!this.deleted && item._bestAttachmentState?.key && this.key === item._bestAttachmentState.key) {
item._bestAttachmentState.exists = exists;
if (!this.deleted
&& parentItem._bestAttachmentState?.key
&& this.key === parentItem._bestAttachmentState.key) {
parentItem._bestAttachmentState.exists = exists;
}
else {
item.clearBestAttachmentState();
parentItem.clearBestAttachmentState();
}
};