Fix attachment icon remains after deleting attachment. Fix #3779
This commit is contained in:
parent
d0299a1acc
commit
16fa1ac893
2 changed files with 22 additions and 1 deletions
|
@ -2744,7 +2744,7 @@ Zotero.Item.prototype._updateAttachmentStates = function (exists) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (item._bestAttachmentState?.key && this.key === item._bestAttachmentState.key) {
|
||||
if (!this.deleted && item._bestAttachmentState?.key && this.key === item._bestAttachmentState.key) {
|
||||
item._bestAttachmentState.exists = exists;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1280,6 +1280,27 @@ describe("Zotero.Item", function () {
|
|||
{ type: 'image', exists: true, key: childItem.key }
|
||||
);
|
||||
});
|
||||
|
||||
it("should update best attachment state when attachment is trashed", async function () {
|
||||
var parentItem = await createDataObject('item');
|
||||
var file = getTestDataDirectory();
|
||||
file.append('test.png');
|
||||
var childItem = await Zotero.Attachments.importFromFile({
|
||||
file,
|
||||
parentItemID: parentItem.id
|
||||
});
|
||||
|
||||
await parentItem.getBestAttachmentState();
|
||||
childItem._updateAttachmentStates(true);
|
||||
assert.deepEqual(
|
||||
parentItem.getBestAttachmentStateCached(),
|
||||
{ type: 'image', exists: true, key: childItem.key }
|
||||
);
|
||||
|
||||
await Zotero.Items.trashTx([childItem.id]);
|
||||
childItem._updateAttachmentStates(true);
|
||||
assert.deepEqual(parentItem.getBestAttachmentStateCached(), { type: null });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue