Skip to content

Commit 059a420

Browse files
authored
fix: add thumbnail info on gallery press handlers (#2911)
* fix: add thumbnail info on gallery press handlers * fix: pr review comments
1 parent 9cf8832 commit 059a420

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

package/src/components/Attachment/Gallery.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ const GalleryThumbnail = <
332332
onLongPress={(event) => {
333333
if (onLongPress) {
334334
onLongPress({
335+
additionalInfo: { thumbnail },
335336
emitter: 'gallery',
336337
event,
337338
});
@@ -340,6 +341,7 @@ const GalleryThumbnail = <
340341
onPress={(event) => {
341342
if (onPress) {
342343
onPress({
344+
additionalInfo: { thumbnail },
343345
defaultHandler: defaultOnPress,
344346
emitter: 'gallery',
345347
event,
@@ -349,6 +351,7 @@ const GalleryThumbnail = <
349351
onPressIn={(event) => {
350352
if (onPressIn) {
351353
onPressIn({
354+
additionalInfo: { thumbnail },
352355
defaultHandler: defaultOnPress,
353356
emitter: 'gallery',
354357
event,

package/src/components/Message/Message.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
isEditedMessage,
4141
MessageStatusTypes,
4242
} from '../../utils/utils';
43+
import type { Thumbnail } from '../Attachment/utils/buildGallery/types';
4344

4445
import {
4546
isMessageWithStylesReadByAndDateSeparator,
@@ -55,35 +56,56 @@ export type TouchableEmitter =
5556
| 'messageReplies'
5657
| 'reactionList';
5758

59+
export type TextMentionTouchableHandlerAdditionalInfo<
60+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
61+
> = { user?: UserResponse<StreamChatGenerics> };
62+
5863
export type TextMentionTouchableHandlerPayload<
5964
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
6065
> = {
6166
emitter: 'textMention';
62-
additionalInfo?: { user?: UserResponse<StreamChatGenerics> };
67+
additionalInfo?: TextMentionTouchableHandlerAdditionalInfo<StreamChatGenerics>;
6368
};
6469

70+
export type UrlTouchableHandlerAdditionalInfo = { url?: string };
71+
6572
export type UrlTouchableHandlerPayload = {
6673
emitter: 'textLink' | 'card';
67-
additionalInfo?: { url?: string };
74+
additionalInfo?: UrlTouchableHandlerAdditionalInfo;
6875
};
6976

77+
export type FileAttachmentTouchableHandlerAdditionalInfo<
78+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
79+
> = { attachment?: Attachment<StreamChatGenerics> };
80+
7081
export type FileAttachmentTouchableHandlerPayload<
7182
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
7283
> = {
7384
emitter: 'fileAttachment';
74-
additionalInfo?: { attachment?: Attachment<StreamChatGenerics> };
85+
additionalInfo?: FileAttachmentTouchableHandlerAdditionalInfo<StreamChatGenerics>;
86+
};
87+
88+
export type GalleryThumbnailTouchableHandlerAdditionalInfo = { thumbnail?: Thumbnail };
89+
90+
export type GalleryThumbnailTouchableHandlerPayload = {
91+
emitter: 'gallery';
92+
additionalInfo?: GalleryThumbnailTouchableHandlerAdditionalInfo;
7593
};
7694

7795
export type PressableHandlerPayload = {
7896
defaultHandler?: () => void;
7997
event?: GestureResponderEvent;
8098
} & (
8199
| {
82-
emitter?: Exclude<TouchableEmitter, 'textMention' | 'textLink' | 'card' | 'fileAttachment'>;
100+
emitter?: Exclude<
101+
TouchableEmitter,
102+
'textMention' | 'textLink' | 'card' | 'fileAttachment' | 'gallery'
103+
>;
83104
}
84105
| TextMentionTouchableHandlerPayload
85106
| UrlTouchableHandlerPayload
86107
| FileAttachmentTouchableHandlerPayload
108+
| GalleryThumbnailTouchableHandlerPayload
87109
);
88110

89111
export type MessagePressableHandlerPayload<

0 commit comments

Comments
 (0)