Skip to content

Commit 9df8e59

Browse files
authored
feat: add asset url for file attachment's press event emitter (#1637)
* feat: add asset url for file attachment's additional info onPress payload * style: rename assetUrl field as url * fix: additionalInfo type needs to be undefined * style: add attachment for the additional info * docs: fixed the extra fileattachment log
1 parent 920a776 commit 9df8e59

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

docusaurus/docs/reactnative/common-content/core-components/channel/props/on_press_message.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ For example:
3434
return;
3535
}
3636

37+
if (emitter === 'fileAttachment') {
38+
console.log(additionalInfo?.attachment);
39+
return;
40+
}
41+
3742
defaultHandler?.();
3843
}}
3944
>

package/src/components/Attachment/FileAttachment.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const FileAttachmentWithContext = <
103103
onLongPress={(event) => {
104104
if (onLongPress) {
105105
onLongPress({
106+
additionalInfo: { attachment },
106107
emitter: 'fileAttachment',
107108
event,
108109
});
@@ -111,6 +112,7 @@ const FileAttachmentWithContext = <
111112
onPress={(event) => {
112113
if (onPress) {
113114
onPress({
115+
additionalInfo: { attachment },
114116
defaultHandler: defaultOnPress,
115117
emitter: 'fileAttachment',
116118
event,
@@ -120,6 +122,7 @@ const FileAttachmentWithContext = <
120122
onPressIn={(event) => {
121123
if (onPressIn) {
122124
onPressIn({
125+
additionalInfo: { attachment },
123126
defaultHandler: defaultOnPress,
124127
emitter: 'fileAttachment',
125128
event,

package/src/components/Message/Message.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,23 @@ export type UrlTouchableHandlerPayload = {
7373
additionalInfo?: { url?: string };
7474
};
7575

76+
export type FileAttachmentTouchableHandlerPayload<
77+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
78+
> = {
79+
emitter: 'fileAttachment';
80+
additionalInfo?: { attachment?: Attachment<StreamChatGenerics> };
81+
};
82+
7683
export type TouchableHandlerPayload = {
7784
defaultHandler?: () => void;
7885
event?: GestureResponderEvent;
7986
} & (
8087
| {
81-
emitter?: TouchableEmitter;
88+
emitter?: Exclude<TouchableEmitter, 'textMention' | 'textLink' | 'card' | 'fileAttachment'>;
8289
}
8390
| TextMentionTouchableHandlerPayload
8491
| UrlTouchableHandlerPayload
92+
| FileAttachmentTouchableHandlerPayload
8593
);
8694

8795
export type MessageTouchableHandlerPayload<

0 commit comments

Comments
 (0)