stream-chat-react-native-core 4.1.3 → 4.2.0-beta.1
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.
- package/lib/commonjs/components/Attachment/Attachment.js +16 -10
- package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Giphy.js +61 -40
- package/lib/commonjs/components/Attachment/Giphy.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +16 -13
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +42 -20
- package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/utils/theme.js +1 -0
- package/lib/commonjs/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Attachment.js +16 -10
- package/lib/module/components/Attachment/Attachment.js.map +1 -1
- package/lib/module/components/Attachment/Giphy.js +61 -40
- package/lib/module/components/Attachment/Giphy.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +16 -13
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +2 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageContent.js +42 -20
- package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/contexts/themeContext/utils/theme.js +1 -0
- package/lib/module/contexts/themeContext/utils/theme.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Attachment.d.ts +2 -2
- package/lib/typescript/components/Attachment/Giphy.d.ts +2 -2
- package/lib/typescript/components/Channel/Channel.d.ts +2 -2
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +1 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +5 -1
- package/lib/typescript/contexts/themeContext/utils/theme.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/Attachment/Attachment.tsx +29 -4
- package/src/components/Attachment/Giphy.tsx +55 -22
- package/src/components/Attachment/__tests__/Attachment.test.js +41 -0
- package/src/components/Channel/Channel.tsx +4 -1
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +2 -0
- package/src/components/Message/MessageSimple/MessageContent.tsx +20 -13
- package/src/contexts/messagesContext/MessagesContext.tsx +5 -2
- package/src/contexts/themeContext/utils/theme.ts +1 -0
- package/src/version.json +1 -1
|
@@ -71,6 +71,47 @@ describe('Attachment', () => {
|
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
+
it('"giphy" attachment size should be customisable', async () => {
|
|
75
|
+
const attachment = generateGiphyAttachment();
|
|
76
|
+
attachment.giphy = {
|
|
77
|
+
fixed_height: {
|
|
78
|
+
height: '200',
|
|
79
|
+
url: 'https://media1.giphy.com/media/test/fixed_height.gif',
|
|
80
|
+
width: '375',
|
|
81
|
+
},
|
|
82
|
+
original: {
|
|
83
|
+
height: '256',
|
|
84
|
+
url: 'https://media1.giphy.com/media/test/original.gif',
|
|
85
|
+
width: '480',
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
const { getByTestId: getByTestIdFixedHeight } = render(
|
|
89
|
+
getAttachmentComponent({ attachment, giphyVersion: 'fixed_height' }),
|
|
90
|
+
);
|
|
91
|
+
const { getByTestId: getByTestIdOriginal } = render(
|
|
92
|
+
getAttachmentComponent({ attachment, giphyVersion: 'original' }),
|
|
93
|
+
);
|
|
94
|
+
await waitFor(() => {
|
|
95
|
+
const checkImageProps = (imageProps, specificSizedGiphyData) => {
|
|
96
|
+
let imageStyle = imageProps.style;
|
|
97
|
+
if (Array.isArray(imageStyle)) {
|
|
98
|
+
imageStyle = Object.assign({}, ...imageStyle);
|
|
99
|
+
}
|
|
100
|
+
expect(imageStyle.height).toBe(parseFloat(specificSizedGiphyData.height));
|
|
101
|
+
expect(imageStyle.width).toBe(parseFloat(specificSizedGiphyData.width));
|
|
102
|
+
expect(imageProps.source.uri).toBe(specificSizedGiphyData.url);
|
|
103
|
+
};
|
|
104
|
+
checkImageProps(
|
|
105
|
+
getByTestIdFixedHeight('giphy-attachment-image').props,
|
|
106
|
+
attachment.giphy.fixed_height,
|
|
107
|
+
);
|
|
108
|
+
checkImageProps(
|
|
109
|
+
getByTestIdOriginal('giphy-attachment-image').props,
|
|
110
|
+
attachment.giphy.original,
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
74
115
|
it('should render UrlPreview component if attachment has title_link or og_scrape_url', async () => {
|
|
75
116
|
const attachment = generateImageAttachment({
|
|
76
117
|
og_scrape_url: uuidv4(),
|
|
@@ -238,6 +238,7 @@ export type ChannelPropsWithContext<
|
|
|
238
238
|
| 'formatDate'
|
|
239
239
|
| 'Gallery'
|
|
240
240
|
| 'Giphy'
|
|
241
|
+
| 'giphyVersion'
|
|
241
242
|
| 'handleBlock'
|
|
242
243
|
| 'handleCopy'
|
|
243
244
|
| 'handleDelete'
|
|
@@ -366,7 +367,7 @@ export type ChannelPropsWithContext<
|
|
|
366
367
|
maxMessageLength?: number;
|
|
367
368
|
messageId?: string;
|
|
368
369
|
newMessageStateUpdateThrottleInterval?: number;
|
|
369
|
-
overrideOwnCapabilities?: OwnCapabilitiesContextValue
|
|
370
|
+
overrideOwnCapabilities?: Partial<OwnCapabilitiesContextValue>;
|
|
370
371
|
stateUpdateThrottleInterval?: number;
|
|
371
372
|
/**
|
|
372
373
|
* Tells if channel is rendering a thread list
|
|
@@ -426,6 +427,7 @@ const ChannelWithContext = <
|
|
|
426
427
|
Gallery = GalleryDefault,
|
|
427
428
|
Giphy = GiphyDefault,
|
|
428
429
|
giphyEnabled,
|
|
430
|
+
giphyVersion = 'fixed_height',
|
|
429
431
|
globalUnreadCountLimit = 255,
|
|
430
432
|
handleBlock,
|
|
431
433
|
handleCopy,
|
|
@@ -1672,6 +1674,7 @@ const ChannelWithContext = <
|
|
|
1672
1674
|
formatDate,
|
|
1673
1675
|
Gallery,
|
|
1674
1676
|
Giphy,
|
|
1677
|
+
giphyVersion,
|
|
1675
1678
|
handleBlock,
|
|
1676
1679
|
handleCopy,
|
|
1677
1680
|
handleDelete,
|
|
@@ -27,6 +27,7 @@ export const useCreateMessagesContext = <
|
|
|
27
27
|
formatDate,
|
|
28
28
|
Gallery,
|
|
29
29
|
Giphy,
|
|
30
|
+
giphyVersion,
|
|
30
31
|
handleBlock,
|
|
31
32
|
handleCopy,
|
|
32
33
|
handleDelete,
|
|
@@ -111,6 +112,7 @@ export const useCreateMessagesContext = <
|
|
|
111
112
|
formatDate,
|
|
112
113
|
Gallery,
|
|
113
114
|
Giphy,
|
|
115
|
+
giphyVersion,
|
|
114
116
|
handleBlock,
|
|
115
117
|
handleCopy,
|
|
116
118
|
handleDelete,
|
|
@@ -185,7 +185,14 @@ const MessageContentWithContext = <
|
|
|
185
185
|
|
|
186
186
|
const hasThreadReplies = !!message?.reply_count;
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
let noBorder = onlyEmojis && !message.quoted_message;
|
|
189
|
+
if (otherAttachments.length) {
|
|
190
|
+
if (otherAttachments[0].type === 'giphy' && !isMyMessage) {
|
|
191
|
+
noBorder = false;
|
|
192
|
+
} else {
|
|
193
|
+
noBorder = true;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
189
196
|
|
|
190
197
|
const isMessageTypeDeleted = message.type === 'deleted';
|
|
191
198
|
|
|
@@ -200,18 +207,18 @@ const MessageContentWithContext = <
|
|
|
200
207
|
);
|
|
201
208
|
}
|
|
202
209
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
let backgroundColor = grey_gainsboro;
|
|
211
|
+
if (onlyEmojis && !message.quoted_message) {
|
|
212
|
+
backgroundColor = transparent;
|
|
213
|
+
} else if (otherAttachments.length) {
|
|
214
|
+
if (otherAttachments[0].type === 'giphy') {
|
|
215
|
+
backgroundColor = message.quoted_message || isMyMessage ? grey_gainsboro : white;
|
|
216
|
+
} else {
|
|
217
|
+
backgroundColor = blue_alice;
|
|
218
|
+
}
|
|
219
|
+
} else if (alignment === 'left' || error) {
|
|
220
|
+
backgroundColor = white;
|
|
221
|
+
}
|
|
215
222
|
|
|
216
223
|
const repliesCurveColor = isMyMessage && !error ? backgroundColor : grey_whisper;
|
|
217
224
|
|
|
@@ -4,7 +4,7 @@ import type { TouchableOpacityProps } from 'react-native';
|
|
|
4
4
|
|
|
5
5
|
import type { MessagePinnedHeaderProps } from 'src/components/Message/MessageSimple/MessagePinnedHeader';
|
|
6
6
|
|
|
7
|
-
import type { ChannelState, MessageResponse } from 'stream-chat';
|
|
7
|
+
import type { Attachment, ChannelState, MessageResponse } from 'stream-chat';
|
|
8
8
|
|
|
9
9
|
import type { AttachmentProps } from '../../components/Attachment/Attachment';
|
|
10
10
|
import type { AttachmentActionsProps } from '../../components/Attachment/AttachmentActions';
|
|
@@ -107,7 +107,10 @@ export type MessagesContextValue<
|
|
|
107
107
|
* Defaults to: [Giphy](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/Giphy.tsx)
|
|
108
108
|
*/
|
|
109
109
|
Giphy: React.ComponentType<GiphyProps<StreamChatGenerics>>;
|
|
110
|
-
|
|
110
|
+
/**
|
|
111
|
+
* The giphy version to render - check the keys of the [Image Object](https://developers.giphy.com/docs/api/schema#image-object) for possible values. Uses 'fixed_height' by default
|
|
112
|
+
* */
|
|
113
|
+
giphyVersion: keyof NonNullable<Attachment['giphy']>;
|
|
111
114
|
/**
|
|
112
115
|
* When true, messageList will be scrolled at first unread message, when opened.
|
|
113
116
|
*/
|
|
@@ -20,6 +20,7 @@ export const Colors = {
|
|
|
20
20
|
grey_gainsboro: '#DBDBDB',
|
|
21
21
|
grey_whisper: '#ECEBEB',
|
|
22
22
|
icon_background: '#FFFFFF',
|
|
23
|
+
label_bg_transparent: '#00000033', // 33 = 20% opacity
|
|
23
24
|
modal_shadow: '#00000099', // 99 = 60% opacity; x=0, y= 1, radius=4
|
|
24
25
|
overlay: '#000000CC', // CC = 80% opacity
|
|
25
26
|
shadow_icon: '#00000040', // 40 = 25% opacity; x=0, y=0, radius=4
|
package/src/version.json
CHANGED