stream-chat-react-native-core 4.3.0-beta.3 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/lib/commonjs/components/Attachment/Attachment.js +21 -12
  2. package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
  3. package/lib/commonjs/components/Channel/Channel.js +15 -13
  4. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  5. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +2 -0
  6. package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  7. package/lib/commonjs/components/Channel/hooks/useCreateOwnCapabilitiesContext.js +6 -3
  8. package/lib/commonjs/components/Channel/hooks/useCreateOwnCapabilitiesContext.js.map +1 -1
  9. package/lib/commonjs/components/Message/Message.js +11 -8
  10. package/lib/commonjs/components/Message/Message.js.map +1 -1
  11. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +28 -23
  12. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
  13. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +7 -6
  14. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  15. package/lib/commonjs/contexts/messagesContext/MessagesContext.js +2 -2
  16. package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
  17. package/lib/commonjs/version.json +1 -1
  18. package/lib/module/components/Attachment/Attachment.js +21 -12
  19. package/lib/module/components/Attachment/Attachment.js.map +1 -1
  20. package/lib/module/components/Channel/Channel.js +15 -13
  21. package/lib/module/components/Channel/Channel.js.map +1 -1
  22. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +2 -0
  23. package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
  24. package/lib/module/components/Channel/hooks/useCreateOwnCapabilitiesContext.js +6 -3
  25. package/lib/module/components/Channel/hooks/useCreateOwnCapabilitiesContext.js.map +1 -1
  26. package/lib/module/components/Message/Message.js +11 -8
  27. package/lib/module/components/Message/Message.js.map +1 -1
  28. package/lib/module/components/Message/MessageSimple/MessageContent.js +28 -23
  29. package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
  30. package/lib/module/components/Message/MessageSimple/MessageSimple.js +7 -6
  31. package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  32. package/lib/module/contexts/messagesContext/MessagesContext.js +2 -2
  33. package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
  34. package/lib/module/version.json +1 -1
  35. package/lib/typescript/components/Attachment/Attachment.d.ts +2 -2
  36. package/lib/typescript/components/Channel/Channel.d.ts +1 -1
  37. package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
  38. package/lib/typescript/components/Message/Message.d.ts +1 -1
  39. package/lib/typescript/components/Message/MessageSimple/MessageContent.d.ts +1 -1
  40. package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +2 -0
  41. package/package.json +1 -1
  42. package/src/components/Attachment/Attachment.tsx +11 -2
  43. package/src/components/Channel/Channel.tsx +3 -0
  44. package/src/components/Channel/__tests__/isAttachmentEqualHandler.test.js +100 -0
  45. package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
  46. package/src/components/Channel/hooks/useCreateOwnCapabilitiesContext.ts +6 -1
  47. package/src/components/Message/Message.tsx +19 -8
  48. package/src/components/Message/MessageSimple/MessageContent.tsx +23 -14
  49. package/src/components/Message/MessageSimple/MessageSimple.tsx +14 -11
  50. package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +411 -12
  51. package/src/contexts/messagesContext/MessagesContext.tsx +5 -0
  52. package/src/version.json +1 -1
@@ -44,7 +44,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
44
44
  __self: _this,
45
45
  __source: {
46
46
  fileName: _jsxFileName,
47
- lineNumber: 56,
47
+ lineNumber: 57,
48
48
  columnNumber: 12
49
49
  }
50
50
  });
@@ -55,7 +55,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
55
55
  __self: _this,
56
56
  __source: {
57
57
  fileName: _jsxFileName,
58
- lineNumber: 63,
58
+ lineNumber: 64,
59
59
  columnNumber: 12
60
60
  }
61
61
  }));
@@ -67,7 +67,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
67
67
  __self: _this,
68
68
  __source: {
69
69
  fileName: _jsxFileName,
70
- lineNumber: 69,
70
+ lineNumber: 70,
71
71
  columnNumber: 9
72
72
  }
73
73
  }), hasAttachmentActions && _react["default"].createElement(AttachmentActions, (0, _extends2["default"])({
@@ -76,7 +76,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
76
76
  __self: _this,
77
77
  __source: {
78
78
  fileName: _jsxFileName,
79
- lineNumber: 71,
79
+ lineNumber: 72,
80
80
  columnNumber: 11
81
81
  }
82
82
  })));
@@ -88,7 +88,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
88
88
  __self: _this,
89
89
  __source: {
90
90
  fileName: _jsxFileName,
91
- lineNumber: 78,
91
+ lineNumber: 79,
92
92
  columnNumber: 12
93
93
  }
94
94
  });
@@ -100,7 +100,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
100
100
  __self: _this,
101
101
  __source: {
102
102
  fileName: _jsxFileName,
103
- lineNumber: 84,
103
+ lineNumber: 85,
104
104
  columnNumber: 7
105
105
  }
106
106
  });
@@ -111,7 +111,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
111
111
  __self: _this,
112
112
  __source: {
113
113
  fileName: _jsxFileName,
114
- lineNumber: 91,
114
+ lineNumber: 92,
115
115
  columnNumber: 9
116
116
  }
117
117
  })), _react["default"].createElement(AttachmentActions, (0, _extends2["default"])({
@@ -120,7 +120,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
120
120
  __self: _this,
121
121
  __source: {
122
122
  fileName: _jsxFileName,
123
- lineNumber: 92,
123
+ lineNumber: 93,
124
124
  columnNumber: 9
125
125
  }
126
126
  })));
@@ -129,7 +129,7 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
129
129
  __self: _this,
130
130
  __source: {
131
131
  fileName: _jsxFileName,
132
- lineNumber: 96,
132
+ lineNumber: 97,
133
133
  columnNumber: 12
134
134
  }
135
135
  }));
@@ -139,10 +139,17 @@ var AttachmentWithContext = function AttachmentWithContext(props) {
139
139
  var areEqual = function areEqual(prevProps, nextProps) {
140
140
  var _prevAttachment$actio, _nextAttachment$actio;
141
141
 
142
- var prevAttachment = prevProps.attachment;
142
+ var prevAttachment = prevProps.attachment,
143
+ isAttachmentEqual = prevProps.isAttachmentEqual;
143
144
  var nextAttachment = nextProps.attachment;
144
145
  var attachmentEqual = ((_prevAttachment$actio = prevAttachment.actions) == null ? void 0 : _prevAttachment$actio.length) === ((_nextAttachment$actio = nextAttachment.actions) == null ? void 0 : _nextAttachment$actio.length) && prevAttachment.image_url === nextAttachment.image_url && prevAttachment.thumb_url === nextAttachment.thumb_url;
145
- return attachmentEqual;
146
+ if (!attachmentEqual) return false;
147
+
148
+ if (isAttachmentEqual) {
149
+ return isAttachmentEqual(prevAttachment, nextAttachment);
150
+ }
151
+
152
+ return true;
146
153
  };
147
154
 
148
155
  var MemoizedAttachment = _react["default"].memo(AttachmentWithContext, areEqual);
@@ -164,6 +171,7 @@ var Attachment = function Attachment(props) {
164
171
  ContextGallery = _useMessagesContext.Gallery,
165
172
  ContextGiphy = _useMessagesContext.Giphy,
166
173
  ContextGiphyVersion = _useMessagesContext.giphyVersion,
174
+ isAttachmentEqual = _useMessagesContext.isAttachmentEqual,
167
175
  ContextUrlPreview = _useMessagesContext.UrlPreview;
168
176
 
169
177
  if (!attachment) {
@@ -185,11 +193,12 @@ var Attachment = function Attachment(props) {
185
193
  Gallery: Gallery,
186
194
  Giphy: Giphy,
187
195
  giphyVersion: giphyVersion,
196
+ isAttachmentEqual: isAttachmentEqual,
188
197
  UrlPreview: UrlPreview,
189
198
  __self: _this,
190
199
  __source: {
191
200
  fileName: _jsxFileName,
192
- lineNumber: 179,
201
+ lineNumber: 187,
193
202
  columnNumber: 5
194
203
  }
195
204
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["Attachment.tsx"],"names":["AttachmentWithContext","props","attachment","AttachmentActions","Card","FileAttachment","Gallery","Giphy","giphyVersion","UrlPreview","hasAttachmentActions","actions","length","type","title_link","og_scrape_url","image_url","thumb_url","id","asset_url","areEqual","prevProps","nextProps","prevAttachment","nextAttachment","attachmentEqual","MemoizedAttachment","React","memo","Attachment","PropAttachmentActions","PropCard","PropFileAttachment","PropGallery","PropGiphy","PropGiphyVersion","PropUrlPreview","ContextAttachmentActions","ContextCard","ContextFileAttachment","ContextGallery","ContextGiphy","ContextGiphyVersion","ContextUrlPreview","AttachmentActionsDefault","CardDefault","FileAttachmentDefault","GalleryDefault","GiphyDefault"],"mappings":";;;;;;;;;AAAA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;AA2BA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAG5BC,KAH4B,EAIzB;AAAA;;AACH,MACEC,UADF,GASID,KATJ,CACEC,UADF;AAAA,MAEEC,iBAFF,GASIF,KATJ,CAEEE,iBAFF;AAAA,MAGEC,IAHF,GASIH,KATJ,CAGEG,IAHF;AAAA,MAIEC,cAJF,GASIJ,KATJ,CAIEI,cAJF;AAAA,MAKEC,OALF,GASIL,KATJ,CAKEK,OALF;AAAA,MAMEC,KANF,GASIN,KATJ,CAMEM,KANF;AAAA,MAOEC,YAPF,GASIP,KATJ,CAOEO,YAPF;AAAA,MAQEC,UARF,GASIR,KATJ,CAQEQ,UARF;AAWA,MAAMC,oBAAoB,GAAG,CAAC,yBAACR,UAAU,CAACS,OAAZ,aAAC,oBAAoBC,MAArB,CAA9B;;AAEA,MAAIV,UAAU,CAACW,IAAX,KAAoB,OAApB,IAA+BX,UAAU,CAACW,IAAX,KAAoB,OAAvD,EAAgE;AAC9D,WAAO,gCAAC,KAAD;AAAO,MAAA,UAAU,EAAEX,UAAnB;AAA+B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EElC,IAFF;AAAA,MAGkBmC,qBAHlB,uBAGElC,cAHF;AAAA,MAIWmC,cAJX,uBAIElC,OAJF;AAAA,MAKSmC,YALT,uBAKElC,KALF;AAAA,MAMgBmC,mBANhB,uBAMElC,YANF;AAAA,MAOcmC,iBAPd,uBAOElC,UAPF;;AAUA,MAAI,CAACP,UAAL,EAAiB;AACf,WAAO,IAAP;AACD;;AAED,MAAMC,iBAAiB,GACrB2B,qBAAqB,IAAIO,wBAAzB,IAAqDO,oCADvD;AAEA,MAAMxC,IAAI,GAAG2B,QAAQ,IAAIO,WAAZ,IAA2BO,UAAxC;AACA,MAAMxC,cAAc,GAAG2B,kBAAkB,IAAIO,qBAAtB,IAA+CO,8BAAtE;AACA,MAAMxC,OAAO,GAAG2B,WAAW,IAAIO,cAAf,IAAiCO,gBAAjD;AACA,MAAMxC,KAAK,GAAG2B,SAAS,IAAIO,YAAb,IAA6BO,YAA3C;AACA,MAAMvC,UAAU,GAAG2B,cAAc,IAAIO,iBAAlB,IAAuCE,UAA1D;AACA,MAAMrC,YAAY,GAAG2B,gBAAgB,IAAIO,mBAAzC;AAEA,SACE,gCAAC,kBAAD;AAEIxC,IAAAA,UAAU,EAAVA,UAFJ;AAGIC,IAAAA,iBAAiB,EAAjBA,iBAHJ;AAIIC,IAAAA,IAAI,EAAJA,IAJJ;AAKIC,IAAAA,cAAc,EAAdA,cALJ;AAMIC,IAAAA,OAAO,EAAPA,OANJ;AAOIC,IAAAA,KAAK,EAALA,KAPJ;AAQIC,IAAAA,YAAY,EAAZA,YARJ;AASIC,IAAAA,UAAU,EAAVA,UATJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADF;AAcD,CArDM","sourcesContent":["import React from 'react';\n\nimport type { Attachment as AttachmentType } from 'stream-chat';\n\nimport { AttachmentActions as AttachmentActionsDefault } from '../../components/Attachment/AttachmentActions';\nimport { Card as CardDefault } from '../../components/Attachment/Card';\nimport { FileAttachment as FileAttachmentDefault } from '../../components/Attachment/FileAttachment';\nimport { Gallery as GalleryDefault } from '../../components/Attachment/Gallery';\nimport { Giphy as GiphyDefault } from '../../components/Attachment/Giphy';\nimport {\n MessagesContextValue,\n useMessagesContext,\n} from '../../contexts/messagesContext/MessagesContext';\n\nimport type { DefaultStreamChatGenerics } from '../../types/types';\n\nexport type ActionHandler = (name: string, value: string) => void;\n\nexport type AttachmentPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<\n MessagesContextValue<StreamChatGenerics>,\n | 'AttachmentActions'\n | 'Card'\n | 'FileAttachment'\n | 'Gallery'\n | 'giphyVersion'\n | 'Giphy'\n | 'UrlPreview'\n> & {\n /**\n * The attachment to render\n */\n attachment: AttachmentType<StreamChatGenerics>;\n};\n\nconst AttachmentWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AttachmentPropsWithContext<StreamChatGenerics>,\n) => {\n const {\n attachment,\n AttachmentActions,\n Card,\n FileAttachment,\n Gallery,\n Giphy,\n giphyVersion,\n UrlPreview,\n } = props;\n\n const hasAttachmentActions = !!attachment.actions?.length;\n\n if (attachment.type === 'giphy' || attachment.type === 'imgur') {\n return <Giphy attachment={attachment} giphyVersion={giphyVersion} />;\n }\n\n if (\n (attachment.title_link || attachment.og_scrape_url) &&\n (attachment.image_url || attachment.thumb_url)\n ) {\n return <UrlPreview {...attachment} />;\n }\n\n if (attachment.type === 'image') {\n return (\n <>\n <Gallery images={[attachment]} />\n {hasAttachmentActions && (\n <AttachmentActions key={`key-actions-${attachment.id}`} {...attachment} />\n )}\n </>\n );\n }\n\n if (attachment.type === 'file' || attachment.type === 'audio') {\n return <FileAttachment attachment={attachment} />;\n }\n\n if (attachment.type === 'video' && attachment.asset_url) {\n return (\n // TODO: Put in video component\n <FileAttachment attachment={attachment} />\n );\n }\n\n if (hasAttachmentActions) {\n return (\n <>\n <Card {...attachment} />\n <AttachmentActions key={`key-actions-${attachment.id}`} {...attachment} />\n </>\n );\n } else {\n return <Card {...attachment} />;\n }\n};\n\nconst areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(\n prevProps: AttachmentPropsWithContext<StreamChatGenerics>,\n nextProps: AttachmentPropsWithContext<StreamChatGenerics>,\n) => {\n const { attachment: prevAttachment } = prevProps;\n const { attachment: nextAttachment } = nextProps;\n\n const attachmentEqual =\n prevAttachment.actions?.length === nextAttachment.actions?.length &&\n prevAttachment.image_url === nextAttachment.image_url &&\n prevAttachment.thumb_url === nextAttachment.thumb_url;\n\n return attachmentEqual;\n};\n\nconst MemoizedAttachment = React.memo(\n AttachmentWithContext,\n areEqual,\n) as typeof AttachmentWithContext;\n\nexport type AttachmentProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<\n Pick<\n MessagesContextValue<StreamChatGenerics>,\n | 'AttachmentActions'\n | 'Card'\n | 'FileAttachment'\n | 'Gallery'\n | 'Giphy'\n | 'giphyVersion'\n | 'UrlPreview'\n >\n> &\n Pick<AttachmentPropsWithContext<StreamChatGenerics>, 'attachment'>;\n\n/**\n * Attachment - The message attachment\n */\nexport const Attachment = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AttachmentProps<StreamChatGenerics>,\n) => {\n const {\n attachment,\n AttachmentActions: PropAttachmentActions,\n Card: PropCard,\n FileAttachment: PropFileAttachment,\n Gallery: PropGallery,\n Giphy: PropGiphy,\n giphyVersion: PropGiphyVersion,\n UrlPreview: PropUrlPreview,\n } = props;\n\n const {\n AttachmentActions: ContextAttachmentActions,\n Card: ContextCard,\n FileAttachment: ContextFileAttachment,\n Gallery: ContextGallery,\n Giphy: ContextGiphy,\n giphyVersion: ContextGiphyVersion,\n UrlPreview: ContextUrlPreview,\n } = useMessagesContext<StreamChatGenerics>();\n\n if (!attachment) {\n return null;\n }\n\n const AttachmentActions =\n PropAttachmentActions || ContextAttachmentActions || AttachmentActionsDefault;\n const Card = PropCard || ContextCard || CardDefault;\n const FileAttachment = PropFileAttachment || ContextFileAttachment || FileAttachmentDefault;\n const Gallery = PropGallery || ContextGallery || GalleryDefault;\n const Giphy = PropGiphy || ContextGiphy || GiphyDefault;\n const UrlPreview = PropUrlPreview || ContextUrlPreview || CardDefault;\n const giphyVersion = PropGiphyVersion || ContextGiphyVersion;\n\n return (\n <MemoizedAttachment\n {...{\n attachment,\n AttachmentActions,\n Card,\n FileAttachment,\n Gallery,\n Giphy,\n giphyVersion,\n UrlPreview,\n }}\n />\n );\n};\n"]}
1
+ {"version":3,"sources":["Attachment.tsx"],"names":["AttachmentWithContext","props","attachment","AttachmentActions","Card","FileAttachment","Gallery","Giphy","giphyVersion","UrlPreview","hasAttachmentActions","actions","length","type","title_link","og_scrape_url","image_url","thumb_url","id","asset_url","areEqual","prevProps","nextProps","prevAttachment","isAttachmentEqual","nextAttachment","attachmentEqual","MemoizedAttachment","React","memo","Attachment","PropAttachmentActions","PropCard","PropFileAttachment","PropGallery","PropGiphy","PropGiphyVersion","PropUrlPreview","ContextAttachmentActions","ContextCard","ContextFileAttachment","ContextGallery","ContextGiphy","ContextGiphyVersion","ContextUrlPreview","AttachmentActionsDefault","CardDefault","FileAttachmentDefault","GalleryDefault","GiphyDefault"],"mappings":";;;;;;;;;AAAA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;AA4BA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAG5BC,KAH4B,EAIzB;AAAA;;AACH,MACEC,UADF,GASID,KATJ,CACEC,UADF;AAAA,MAEEC,iBAFF,GASIF,KATJ,CAEEE,iBAFF;AAAA,MAGEC,IAHF,GASIH,KATJ,CAGEG,IAHF;AAAA,MAIEC,cAJF,GASIJ,KATJ,CAIEI,cAJF;AAAA,MAKEC,OALF,GASIL,KATJ,CAKEK,OALF;AAAA,MAMEC,KANF,GASIN,KATJ,CAMEM,KANF;AAAA,MAOEC,YAPF,GASIP,KATJ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SACE,gCAAC,kBAAD;AAEIzC,IAAAA,UAAU,EAAVA,UAFJ;AAGIC,IAAAA,iBAAiB,EAAjBA,iBAHJ;AAIIC,IAAAA,IAAI,EAAJA,IAJJ;AAKIC,IAAAA,cAAc,EAAdA,cALJ;AAMIC,IAAAA,OAAO,EAAPA,OANJ;AAOIC,IAAAA,KAAK,EAALA,KAPJ;AAQIC,IAAAA,YAAY,EAAZA,YARJ;AASIgB,IAAAA,iBAAiB,EAAjBA,iBATJ;AAUIf,IAAAA,UAAU,EAAVA,UAVJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IADF;AAeD,CAvDM","sourcesContent":["import React from 'react';\n\nimport type { Attachment as AttachmentType } from 'stream-chat';\n\nimport { AttachmentActions as AttachmentActionsDefault } from '../../components/Attachment/AttachmentActions';\nimport { Card as CardDefault } from '../../components/Attachment/Card';\nimport { FileAttachment as FileAttachmentDefault } from '../../components/Attachment/FileAttachment';\nimport { Gallery as GalleryDefault } from '../../components/Attachment/Gallery';\nimport { Giphy as GiphyDefault } from '../../components/Attachment/Giphy';\nimport {\n MessagesContextValue,\n useMessagesContext,\n} from '../../contexts/messagesContext/MessagesContext';\n\nimport type { DefaultStreamChatGenerics } from '../../types/types';\n\nexport type ActionHandler = (name: string, value: string) => void;\n\nexport type AttachmentPropsWithContext<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Pick<\n MessagesContextValue<StreamChatGenerics>,\n | 'AttachmentActions'\n | 'Card'\n | 'FileAttachment'\n | 'Gallery'\n | 'giphyVersion'\n | 'Giphy'\n | 'isAttachmentEqual'\n | 'UrlPreview'\n> & {\n /**\n * The attachment to render\n */\n attachment: AttachmentType<StreamChatGenerics>;\n};\n\nconst AttachmentWithContext = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AttachmentPropsWithContext<StreamChatGenerics>,\n) => {\n const {\n attachment,\n AttachmentActions,\n Card,\n FileAttachment,\n Gallery,\n Giphy,\n giphyVersion,\n UrlPreview,\n } = props;\n\n const hasAttachmentActions = !!attachment.actions?.length;\n\n if (attachment.type === 'giphy' || attachment.type === 'imgur') {\n return <Giphy attachment={attachment} giphyVersion={giphyVersion} />;\n }\n\n if (\n (attachment.title_link || attachment.og_scrape_url) &&\n (attachment.image_url || attachment.thumb_url)\n ) {\n return <UrlPreview {...attachment} />;\n }\n\n if (attachment.type === 'image') {\n return (\n <>\n <Gallery images={[attachment]} />\n {hasAttachmentActions && (\n <AttachmentActions key={`key-actions-${attachment.id}`} {...attachment} />\n )}\n </>\n );\n }\n\n if (attachment.type === 'file' || attachment.type === 'audio') {\n return <FileAttachment attachment={attachment} />;\n }\n\n if (attachment.type === 'video' && attachment.asset_url) {\n return (\n // TODO: Put in video component\n <FileAttachment attachment={attachment} />\n );\n }\n\n if (hasAttachmentActions) {\n return (\n <>\n <Card {...attachment} />\n <AttachmentActions key={`key-actions-${attachment.id}`} {...attachment} />\n </>\n );\n } else {\n return <Card {...attachment} />;\n }\n};\n\nconst areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(\n prevProps: AttachmentPropsWithContext<StreamChatGenerics>,\n nextProps: AttachmentPropsWithContext<StreamChatGenerics>,\n) => {\n const { attachment: prevAttachment, isAttachmentEqual } = prevProps;\n const { attachment: nextAttachment } = nextProps;\n\n const attachmentEqual =\n prevAttachment.actions?.length === nextAttachment.actions?.length &&\n prevAttachment.image_url === nextAttachment.image_url &&\n prevAttachment.thumb_url === nextAttachment.thumb_url;\n if (!attachmentEqual) return false;\n\n if (isAttachmentEqual) {\n return isAttachmentEqual(prevAttachment, nextAttachment);\n }\n\n return true;\n};\n\nconst MemoizedAttachment = React.memo(\n AttachmentWithContext,\n areEqual,\n) as typeof AttachmentWithContext;\n\nexport type AttachmentProps<\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n> = Partial<\n Pick<\n MessagesContextValue<StreamChatGenerics>,\n | 'AttachmentActions'\n | 'Card'\n | 'FileAttachment'\n | 'Gallery'\n | 'Giphy'\n | 'giphyVersion'\n | 'UrlPreview'\n | 'isAttachmentEqual'\n >\n> &\n Pick<AttachmentPropsWithContext<StreamChatGenerics>, 'attachment'>;\n\n/**\n * Attachment - The message attachment\n */\nexport const Attachment = <\n StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,\n>(\n props: AttachmentProps<StreamChatGenerics>,\n) => {\n const {\n attachment,\n AttachmentActions: PropAttachmentActions,\n Card: PropCard,\n FileAttachment: PropFileAttachment,\n Gallery: PropGallery,\n Giphy: PropGiphy,\n giphyVersion: PropGiphyVersion,\n UrlPreview: PropUrlPreview,\n } = props;\n\n const {\n AttachmentActions: ContextAttachmentActions,\n Card: ContextCard,\n FileAttachment: ContextFileAttachment,\n Gallery: ContextGallery,\n Giphy: ContextGiphy,\n giphyVersion: ContextGiphyVersion,\n isAttachmentEqual,\n UrlPreview: ContextUrlPreview,\n } = useMessagesContext<StreamChatGenerics>();\n\n if (!attachment) {\n return null;\n }\n\n const AttachmentActions =\n PropAttachmentActions || ContextAttachmentActions || AttachmentActionsDefault;\n const Card = PropCard || ContextCard || CardDefault;\n const FileAttachment = PropFileAttachment || ContextFileAttachment || FileAttachmentDefault;\n const Gallery = PropGallery || ContextGallery || GalleryDefault;\n const Giphy = PropGiphy || ContextGiphy || GiphyDefault;\n const UrlPreview = PropUrlPreview || ContextUrlPreview || CardDefault;\n const giphyVersion = PropGiphyVersion || ContextGiphyVersion;\n\n return (\n <MemoizedAttachment\n {...{\n attachment,\n AttachmentActions,\n Card,\n FileAttachment,\n Gallery,\n Giphy,\n giphyVersion,\n isAttachmentEqual,\n UrlPreview,\n }}\n />\n );\n};\n"]}
@@ -343,6 +343,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
343
343
  InputGiphySearch = _props$InputGiphySear === void 0 ? _InputGiphySearch.InputGiphySearch : _props$InputGiphySear,
344
344
  _props$InputReplyStat = props.InputReplyStateHeader,
345
345
  InputReplyStateHeader = _props$InputReplyStat === void 0 ? _InputReplyStateHeader.InputReplyStateHeader : _props$InputReplyStat,
346
+ isAttachmentEqual = props.isAttachmentEqual,
346
347
  keyboardBehavior = props.keyboardBehavior,
347
348
  _props$KeyboardCompat = props.KeyboardCompatibleView,
348
349
  KeyboardCompatibleView = _props$KeyboardCompat === void 0 ? _KeyboardCompatibleView.KeyboardCompatibleView : _props$KeyboardCompat,
@@ -1976,6 +1977,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
1976
1977
  initialScrollToFirstUnreadMessage: initialScrollToFirstUnreadMessage,
1977
1978
  InlineDateSeparator: InlineDateSeparator,
1978
1979
  InlineUnreadIndicator: InlineUnreadIndicator,
1980
+ isAttachmentEqual: isAttachmentEqual,
1979
1981
  legacyImageViewerSwipeBehaviour: legacyImageViewerSwipeBehaviour,
1980
1982
  markdownRules: markdownRules,
1981
1983
  Message: Message,
@@ -2044,7 +2046,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2044
2046
  __self: _this,
2045
2047
  __source: {
2046
2048
  fileName: _jsxFileName,
2047
- lineNumber: 1767,
2049
+ lineNumber: 1770,
2048
2050
  columnNumber: 12
2049
2051
  }
2050
2052
  });
@@ -2059,7 +2061,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2059
2061
  __self: _this,
2060
2062
  __source: {
2061
2063
  fileName: _jsxFileName,
2062
- lineNumber: 1772,
2064
+ lineNumber: 1775,
2063
2065
  columnNumber: 7
2064
2066
  }
2065
2067
  }, t('Please select a channel first'));
@@ -2073,7 +2075,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2073
2075
  __self: _this,
2074
2076
  __source: {
2075
2077
  fileName: _jsxFileName,
2076
- lineNumber: 1779,
2078
+ lineNumber: 1782,
2077
2079
  columnNumber: 5
2078
2080
  }
2079
2081
  }), _react["default"].createElement(_ChannelContext.ChannelProvider, {
@@ -2081,7 +2083,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2081
2083
  __self: _this,
2082
2084
  __source: {
2083
2085
  fileName: _jsxFileName,
2084
- lineNumber: 1785,
2086
+ lineNumber: 1788,
2085
2087
  columnNumber: 7
2086
2088
  }
2087
2089
  }, _react["default"].createElement(_OwnCapabilitiesContext.OwnCapabilitiesProvider, {
@@ -2089,7 +2091,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2089
2091
  __self: _this,
2090
2092
  __source: {
2091
2093
  fileName: _jsxFileName,
2092
- lineNumber: 1786,
2094
+ lineNumber: 1789,
2093
2095
  columnNumber: 9
2094
2096
  }
2095
2097
  }, _react["default"].createElement(_TypingContext.TypingProvider, {
@@ -2097,7 +2099,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2097
2099
  __self: _this,
2098
2100
  __source: {
2099
2101
  fileName: _jsxFileName,
2100
- lineNumber: 1787,
2102
+ lineNumber: 1790,
2101
2103
  columnNumber: 11
2102
2104
  }
2103
2105
  }, _react["default"].createElement(_PaginatedMessageListContext.PaginatedMessageListProvider, {
@@ -2105,7 +2107,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2105
2107
  __self: _this,
2106
2108
  __source: {
2107
2109
  fileName: _jsxFileName,
2108
- lineNumber: 1788,
2110
+ lineNumber: 1791,
2109
2111
  columnNumber: 13
2110
2112
  }
2111
2113
  }, _react["default"].createElement(_MessagesContext.MessagesProvider, {
@@ -2113,7 +2115,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2113
2115
  __self: _this,
2114
2116
  __source: {
2115
2117
  fileName: _jsxFileName,
2116
- lineNumber: 1789,
2118
+ lineNumber: 1792,
2117
2119
  columnNumber: 15
2118
2120
  }
2119
2121
  }, _react["default"].createElement(_ThreadContext.ThreadProvider, {
@@ -2121,7 +2123,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2121
2123
  __self: _this,
2122
2124
  __source: {
2123
2125
  fileName: _jsxFileName,
2124
- lineNumber: 1790,
2126
+ lineNumber: 1793,
2125
2127
  columnNumber: 17
2126
2128
  }
2127
2129
  }, _react["default"].createElement(_SuggestionsContext.SuggestionsProvider, {
@@ -2129,7 +2131,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2129
2131
  __self: _this,
2130
2132
  __source: {
2131
2133
  fileName: _jsxFileName,
2132
- lineNumber: 1791,
2134
+ lineNumber: 1794,
2133
2135
  columnNumber: 19
2134
2136
  }
2135
2137
  }, _react["default"].createElement(_MessageInputContext.MessageInputProvider, {
@@ -2137,7 +2139,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2137
2139
  __self: _this,
2138
2140
  __source: {
2139
2141
  fileName: _jsxFileName,
2140
- lineNumber: 1792,
2142
+ lineNumber: 1795,
2141
2143
  columnNumber: 21
2142
2144
  }
2143
2145
  }, _react["default"].createElement(_reactNative.View, {
@@ -2147,7 +2149,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
2147
2149
  __self: _this,
2148
2150
  __source: {
2149
2151
  fileName: _jsxFileName,
2150
- lineNumber: 1793,
2152
+ lineNumber: 1796,
2151
2153
  columnNumber: 23
2152
2154
  }
2153
2155
  }, children))))))))));
@@ -2202,7 +2204,7 @@ var Channel = function Channel(props) {
2202
2204
  __self: _this,
2203
2205
  __source: {
2204
2206
  fileName: _jsxFileName,
2205
- lineNumber: 1850,
2207
+ lineNumber: 1853,
2206
2208
  columnNumber: 5
2207
2209
  }
2208
2210
  }));