Support duplicate attachments in lightbox

This commit is contained in:
Fedor Indutny 2023-09-26 17:38:21 +02:00 committed by GitHub
parent b885ced90d
commit 1a2976dae4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 45 deletions

View file

@ -19,7 +19,7 @@ export type Props = {
loadRecentMediaItems: (id: string, limit: number) => void;
showAllMedia: () => void;
showLightboxWithMedia: (
selectedAttachmentPath: string | undefined,
selectedIndex: number,
media: ReadonlyArray<ReadonlyDeep<MediaItemType>>
) => void;
};
@ -66,9 +66,7 @@ export function ConversationDetailsMediaList({
key={`${mediaItem.message.id}-${mediaItem.index}`}
mediaItem={mediaItem}
i18n={i18n}
onClick={() =>
showLightboxWithMedia(mediaItem.attachment.path, mediaItems)
}
onClick={() => showLightboxWithMedia(mediaItem.index, mediaItems)}
/>
))}
</div>

View file

@ -35,7 +35,7 @@ export function AttachmentSection({
const { message, index, attachment } = mediaItem;
const onClick = () => {
onItemClick({ type, message, attachment });
onItemClick({ type, message, attachment, index: mediaItem.index });
};
switch (type) {

View file

@ -29,7 +29,7 @@ export type Props = {
media: Array<MediaItemType>;
saveAttachment: SaveAttachmentActionCreatorType;
showLightboxWithMedia: (
selectedAttachmentPath: string | undefined,
selectedIndex: number,
media: Array<MediaItemType>
) => void;
};
@ -106,7 +106,7 @@ function MediaSection({
}
case 'media': {
showLightboxWithMedia(event.attachment.path, media);
showLightboxWithMedia(event.index, media);
break;
}

View file

@ -7,5 +7,6 @@ import type { AttachmentType } from '../../../../types/Attachment';
export type ItemClickEvent = {
message: Pick<MessageAttributesType, 'sent_at'>;
attachment: AttachmentType;
index: number;
type: 'media' | 'documents';
};