@cometchat/chat-uikit-react-native 5.5.3 → 5.5.4
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/android/.gradle/7.4/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.4/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +5 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +47 -4
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +209 -119
- package/ios/RichTextEditorView.swift +96 -1
- package/ios/SoundPlayer.m +152 -6
- package/package.json +1 -1
- package/react-native-cometchat-ui-kit.podspec +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +43 -24
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +27 -19
- package/src/CometChatMessageList/CometChatMessageList.tsx +60 -25
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +48 -47
|
@@ -270,11 +270,12 @@ export interface CometChatMessageListProps {
|
|
|
270
270
|
*/
|
|
271
271
|
receiptsVisibility?: boolean;
|
|
272
272
|
/**
|
|
273
|
-
* Flag to disable sound for incoming messages.
|
|
273
|
+
* Flag to disable sound for incoming messages. The send sound belongs to the composer
|
|
274
|
+
* (its disableSoundForOutgoingMessages / customSoundForOutgoingMessage props).
|
|
274
275
|
*/
|
|
275
276
|
disableSoundForMessages?: boolean;
|
|
276
277
|
/**
|
|
277
|
-
* Custom sound URL for messages.
|
|
278
|
+
* Custom sound URL for incoming messages.
|
|
278
279
|
*/
|
|
279
280
|
customSoundForMessages?: string;
|
|
280
281
|
/**
|
|
@@ -1514,10 +1515,15 @@ export const CometChatMessageList = memo(
|
|
|
1514
1515
|
return;
|
|
1515
1516
|
}
|
|
1516
1517
|
|
|
1517
|
-
// Create request builder for next messages (messages after the target)
|
|
1518
|
+
// Create request builder for next messages (messages after the target).
|
|
1519
|
+
// Same types/categories filter as the main list: without it the server also returns
|
|
1520
|
+
// the hidden edit/delete records (category "action", type "message"), which no
|
|
1521
|
+
// template renders, so each one became an empty padded row after the jump.
|
|
1518
1522
|
let nextMessagesRequest = new CometChat.MessagesRequestBuilder()
|
|
1519
1523
|
.setLimit(15)
|
|
1520
|
-
.setMessageId(targetMessageId)
|
|
1524
|
+
.setMessageId(targetMessageId)
|
|
1525
|
+
.setTypes(ChatConfigurator.dataSource.getAllMessageTypes())
|
|
1526
|
+
.setCategories(ChatConfigurator.dataSource.getAllMessageCategories());
|
|
1521
1527
|
|
|
1522
1528
|
if (user) {
|
|
1523
1529
|
nextMessagesRequest = nextMessagesRequest.setUID(user.getUid());
|
|
@@ -1618,9 +1624,13 @@ export const CometChatMessageList = memo(
|
|
|
1618
1624
|
const lastReadMsgId = conversation.getLastReadMessageId();
|
|
1619
1625
|
|
|
1620
1626
|
if (lastReadMsgId) {
|
|
1627
|
+
// Filtered like the main list, so the "New messages" marker lands on the
|
|
1628
|
+
// first unread message that is actually shown, not on a hidden edit/delete record.
|
|
1621
1629
|
let request = new CometChat.MessagesRequestBuilder()
|
|
1622
1630
|
.setLimit(1)
|
|
1623
|
-
.setMessageId(Number(lastReadMsgId))
|
|
1631
|
+
.setMessageId(Number(lastReadMsgId))
|
|
1632
|
+
.setTypes(ChatConfigurator.dataSource.getAllMessageTypes())
|
|
1633
|
+
.setCategories(ChatConfigurator.dataSource.getAllMessageCategories());
|
|
1624
1634
|
|
|
1625
1635
|
if (user) request = request.setUID(user.getUid());
|
|
1626
1636
|
if (group) request = request.setGUID(group.getGuid());
|
|
@@ -1994,26 +2004,23 @@ export const CometChatMessageList = memo(
|
|
|
1994
2004
|
return _plainString;
|
|
1995
2005
|
};
|
|
1996
2006
|
|
|
2007
|
+
// Read through a ref: playNotificationSound reaches the SDK/UI listeners, which are
|
|
2008
|
+
// registered once, so with [] deps it kept the sound props from the FIRST render and a
|
|
2009
|
+
// later change to them never took effect.
|
|
2010
|
+
const soundPropsRef = useRef({ disableSoundForMessages, customSoundForMessages });
|
|
2011
|
+
soundPropsRef.current = { disableSoundForMessages, customSoundForMessages };
|
|
2012
|
+
|
|
2013
|
+
// Incoming messages only, as documented. The composer owns the send sound: playing
|
|
2014
|
+
// 'outgoingMessage' here as well made the composer's sound props ineffective, made this
|
|
2015
|
+
// list's "incoming" switch mute sends too, and would double the chime now that the
|
|
2016
|
+
// composer's own sound works (GitHub #117).
|
|
1997
2017
|
const playNotificationSound = useCallback((message: any) => {
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
if (message?.category
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
? "outgoingMessage"
|
|
2005
|
-
: "incomingMessage",
|
|
2006
|
-
customSoundForMessages
|
|
2007
|
-
);
|
|
2008
|
-
} else {
|
|
2009
|
-
CometChatSoundManager.play(
|
|
2010
|
-
// "incomingMessage"
|
|
2011
|
-
loggedInUser.current?.getUid() == message["sender"]["uid"]
|
|
2012
|
-
? "outgoingMessage"
|
|
2013
|
-
: "incomingMessage"
|
|
2014
|
-
);
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2018
|
+
const soundProps = soundPropsRef.current;
|
|
2019
|
+
if (soundProps.disableSoundForMessages) return;
|
|
2020
|
+
if (message?.category !== MessageCategoryConstants.message) return;
|
|
2021
|
+
if (loggedInUser.current?.getUid() === message?.sender?.uid) return;
|
|
2022
|
+
|
|
2023
|
+
CometChatSoundManager.play("incomingMessage", soundProps.customSoundForMessages);
|
|
2017
2024
|
}, []);
|
|
2018
2025
|
|
|
2019
2026
|
const markMessageAsRead = (message: any) => {
|
|
@@ -2988,6 +2995,17 @@ export const CometChatMessageList = memo(
|
|
|
2988
2995
|
setMessagesList(uniqueMsgs);
|
|
2989
2996
|
onLoad && onLoad([...uniqueMsgs].reverse());
|
|
2990
2997
|
setListState("loaded");
|
|
2998
|
+
// Announce the conversation now shown, as getPreviousMessages does for the
|
|
2999
|
+
// first page of any chat. This path fetched on its own and never did, so the
|
|
3000
|
+
// composer never learned it: its next question started a new conversation the
|
|
3001
|
+
// list doesn't track, and later questions were filtered out (ENG-41058).
|
|
3002
|
+
CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccActiveChatChanged, {
|
|
3003
|
+
message: lastMsg,
|
|
3004
|
+
user: user,
|
|
3005
|
+
group: group,
|
|
3006
|
+
theme: mergedTheme,
|
|
3007
|
+
parentMessageId: parentMessageId,
|
|
3008
|
+
});
|
|
2991
3009
|
} else {
|
|
2992
3010
|
setListState("loaded");
|
|
2993
3011
|
onEmpty && onEmpty();
|
|
@@ -3360,6 +3378,19 @@ export const CometChatMessageList = memo(
|
|
|
3360
3378
|
message.getCategory() === MessageCategoryConstants.message
|
|
3361
3379
|
) {
|
|
3362
3380
|
agenticParentMessageIdRef.current = String(message.getId());
|
|
3381
|
+
} else if (
|
|
3382
|
+
isAgenticUser &&
|
|
3383
|
+
!parentMessageId &&
|
|
3384
|
+
agenticParentMessageIdRef.current !== undefined &&
|
|
3385
|
+
!(Number(message.getParentMessageId?.()) > 0) &&
|
|
3386
|
+
message.getType() === MessageTypeConstants.text &&
|
|
3387
|
+
message.getCategory() === MessageCategoryConstants.message
|
|
3388
|
+
) {
|
|
3389
|
+
// A question sent with no parent starts a NEW agent conversation on the server
|
|
3390
|
+
// (for example one sent before this list announced the conversation it loaded).
|
|
3391
|
+
// Follow it, or its reply and every later question in it are filtered out of
|
|
3392
|
+
// the list until a reload (ENG-41058).
|
|
3393
|
+
agenticParentMessageIdRef.current = String(message.getId());
|
|
3363
3394
|
}
|
|
3364
3395
|
if (isAgenticUser && agenticParentMessageIdRef.current !== undefined) {
|
|
3365
3396
|
const streamMessage = createStreamMessage(message);
|
|
@@ -5422,9 +5453,13 @@ export const CometChatMessageList = memo(
|
|
|
5422
5453
|
loadingMessagesRef.current = true;
|
|
5423
5454
|
|
|
5424
5455
|
try {
|
|
5456
|
+
// Filtered like the main list (see getMessagesAroundId): scrolling down after a jump
|
|
5457
|
+
// must not pull in hidden edit/delete records as empty rows either.
|
|
5425
5458
|
let nextMessagesRequest = new CometChat.MessagesRequestBuilder()
|
|
5426
5459
|
.setLimit(30)
|
|
5427
|
-
.setMessageId(newestMessageId)
|
|
5460
|
+
.setMessageId(newestMessageId)
|
|
5461
|
+
.setTypes(ChatConfigurator.dataSource.getAllMessageTypes())
|
|
5462
|
+
.setCategories(ChatConfigurator.dataSource.getAllMessageCategories());
|
|
5428
5463
|
|
|
5429
5464
|
if (user) {
|
|
5430
5465
|
nextMessagesRequest = nextMessagesRequest.setUID(user.getUid());
|
|
@@ -160,56 +160,57 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
160
160
|
);
|
|
161
161
|
|
|
162
162
|
return (
|
|
163
|
-
<View
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
163
|
+
<View onLayout={onLayoutHandler}>
|
|
164
|
+
{/* Only the preview card (image, title, description, link) opens the link. Raw touch
|
|
165
|
+
events reach every ancestor of the touched view, whichever child handles the press, so
|
|
166
|
+
these handlers on the outer view also fired for taps on the message text and its
|
|
167
|
+
"Read more" below, and the image container's second copy made an image tap open the
|
|
168
|
+
link twice (ENG-41080). */}
|
|
169
|
+
<View
|
|
170
|
+
onTouchStart={handleTouchStart}
|
|
171
|
+
onTouchEnd={handleTouchEnd}
|
|
172
|
+
onTouchMove={onTouchMove}
|
|
173
|
+
>
|
|
174
|
+
{imageSource ? (
|
|
175
|
+
<View style={style?.headerImageContainerStyle}>
|
|
176
|
+
<Image
|
|
177
|
+
source={imageSource}
|
|
178
|
+
style={[{ height: imageHeight, width: imageWidth }, style?.headerImageStyle]}
|
|
179
|
+
onError={() => {
|
|
180
|
+
setImageSource(DefaultLinkPreview);
|
|
181
|
+
}}
|
|
182
|
+
/>
|
|
183
|
+
</View>
|
|
184
|
+
) : null}
|
|
185
|
+
|
|
186
|
+
<View style={style?.bodyStyle?.containerStyle}>
|
|
187
|
+
<View style={{ flexDirection: "row" }}>
|
|
188
|
+
<View style={style?.bodyStyle?.titleContainerStyle}>
|
|
189
|
+
<Text style={style?.bodyStyle?.titleStyle} ellipsizeMode='tail'>
|
|
190
|
+
{title}
|
|
191
|
+
</Text>
|
|
192
|
+
</View>
|
|
185
193
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
194
|
+
{!imageSource && !faviconError && (
|
|
195
|
+
<View style={style?.bodyStyle?.faviconContainerStyle}>
|
|
196
|
+
<Image
|
|
197
|
+
source={faviconSource}
|
|
198
|
+
style={style?.bodyStyle?.faviconStyle}
|
|
199
|
+
onError={() => {
|
|
200
|
+
setFaviconError(true);
|
|
201
|
+
}}
|
|
202
|
+
/>
|
|
203
|
+
</View>
|
|
204
|
+
)}
|
|
205
|
+
</View>
|
|
206
|
+
<View style={style?.bodyStyle?.subtitleContainerStyle}>
|
|
207
|
+
<Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
|
|
208
|
+
{description}
|
|
209
|
+
</Text>
|
|
210
|
+
<Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
|
|
211
|
+
{link}
|
|
191
212
|
</Text>
|
|
192
213
|
</View>
|
|
193
|
-
|
|
194
|
-
{!imageSource && !faviconError && (
|
|
195
|
-
<View style={style?.bodyStyle?.faviconContainerStyle}>
|
|
196
|
-
<Image
|
|
197
|
-
source={faviconSource}
|
|
198
|
-
style={style?.bodyStyle?.faviconStyle}
|
|
199
|
-
onError={(err) => {
|
|
200
|
-
setFaviconError(true);
|
|
201
|
-
}}
|
|
202
|
-
/>
|
|
203
|
-
</View>
|
|
204
|
-
)}
|
|
205
|
-
</View>
|
|
206
|
-
<View style={style?.bodyStyle?.subtitleContainerStyle}>
|
|
207
|
-
<Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
|
|
208
|
-
{description}
|
|
209
|
-
</Text>
|
|
210
|
-
<Text style={style?.bodyStyle?.subtitleTitle} numberOfLines={2} ellipsizeMode='tail'>
|
|
211
|
-
{link}
|
|
212
|
-
</Text>
|
|
213
214
|
</View>
|
|
214
215
|
</View>
|
|
215
216
|
{/* Only the card that carries the message text gets this padded row; the others would show an empty band. */}
|