fix(ui mode): make sure key for attachment view is unique

This commit is contained in:
Dmitry Gozman 2024-08-08 16:21:52 +01:00
parent 69287f26bc
commit c641a9d080

View file

@ -131,7 +131,7 @@ export const AttachmentsTab: React.FunctionComponent<{
})}
{attachments.size ? <div className='attachments-section'>Attachments</div> : undefined}
{[...attachments.values()].map((a, i) => {
return <div className='attachment-item' key={`attachment-${i}`}>
return <div className='attachment-item' key={attachmentKey(a, i)}>
<ExpandableAttachment attachment={a} />
</div>;
})}
@ -154,3 +154,7 @@ function downloadURL(attachment: Attachment) {
params.dct = attachment.contentType;
return attachmentURL(attachment, params);
}
function attachmentKey(attachment: Attachment, index: number) {
return index + '-' + (attachment.sha1 ? `sha1-` + attachment.sha1 : `path-` + attachment.path);
}