Load attachment data when handling file renaming on item metadata change

File renaming has a Notifier handler for item modifications that needs
best-attachment titles, but attachments and their item data might not be
loaded even when parent items are. (This came up when migrating fields
from Extra after a global schema update before the main window had
loaded.)
This commit is contained in:
Dan Stillman 2025-12-19 16:16:09 -05:00
parent bf9e5d3a83
commit d6fc071139
2 changed files with 2 additions and 1 deletions

View file

@ -285,6 +285,7 @@ export function registerAutoRenameFileFromParent() {
}
}
await attachmentItem.loadDataType('itemData');
let previousMetadataBaseName = Zotero.Attachments.getFileBaseNameFromItem(
parentItemBefore, { attachmentTitle: attachmentItem.getField('title') }
);

View file

@ -3921,7 +3921,7 @@ Zotero.Item.prototype.getBestAttachments = async function () {
+ "AND IA.itemID NOT IN (SELECT itemID FROM deletedItems) "
+ "ORDER BY contentType='application/pdf' DESC, value=? DESC, dateAdded ASC";
var itemIDs = await Zotero.DB.columnQueryAsync(sql, [this.id, url]);
return this.ObjectsClass.get(itemIDs);
return await this.ObjectsClass.getAsync(itemIDs);
};