@cometchat/chat-uikit-react-native 5.5.1 → 5.5.2
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 +23 -89
- package/android/gradle.properties +5 -5
- package/android/src/main/java/com/reactnativecometchatuikit/CometChatSoundModule.java +5 -1
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +52 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +17 -4
- package/ios/FileManager.m +77 -3
- package/ios/RichTextEditorView.swift +9 -1
- package/package.json +4 -4
- package/react-native-cometchat-ui-kit.podspec +5 -19
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +31 -27
- package/src/CometChatConversations/CometChatConversations.tsx +4 -0
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +35 -28
- package/src/CometChatMessageList/CometChatMessageList.tsx +20 -18
- package/src/CometChatRichTextEditor/index.tsx +2 -1
- package/src/CometChatSearch/CometChatSearch.tsx +10 -5
- package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +56 -17
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +12 -9
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +13 -10
- package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +34 -27
- package/src/extensions/Polls/Polls.tsx +7 -7
- package/src/extensions/Polls/PollsBubble.tsx +2 -2
- package/src/globals.d.ts +6 -0
- package/src/shared/constants/textPatterns.ts +20 -2
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +22 -11
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +26 -14
- package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +8 -0
- package/src/shared/formatters/codeElements.ts +21 -0
- package/src/shared/helper/types/index.ts +5 -0
- package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +4 -4
- package/src/shared/libs/ImageZoom/types/index.ts +2 -0
- package/src/shared/resources/CometChatSoundManager/sound.js +2 -3
- package/src/shared/services/UploadQueueService.ts +7 -0
- package/src/shared/utils/CometChatMessageHelper/index.ts +3 -0
- package/src/shared/utils/MarkdownUtils.ts +11 -4
- package/src/shared/utils/MessageUtils.tsx +7 -5
- package/src/shared/utils/groupMemberAddedRows.ts +28 -0
- package/src/shared/utils/linkPreviewSelection.ts +109 -0
- package/src/shared/utils/mentionTokens.ts +77 -0
- package/src/shared/utils/runAfterInteractions.ts +26 -0
- package/src/shared/utils/stripRichText.ts +2 -1
- package/src/shared/utils/tapGesture.ts +23 -0
- package/src/shared/utils/videoThumbnail.ts +74 -0
- package/src/shared/views/CometChatAttachmentPreview/CometChatAttachmentTile.tsx +21 -13
- package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +13 -15
- package/src/shared/views/CometChatEmojiKeyboard/CometChatEmojiKeyboard.tsx +1 -1
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +2 -1
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +2 -1
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +3 -26
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +4 -2
- package/src/shared/views/CometChatList/Header.tsx +1 -1
- package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +2 -1
- package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +28 -8
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +3 -4
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +36 -4
- package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +2 -1
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +57 -30
- package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +0 -478
- package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +0 -613
- package/src/CometChatMessageList/SEARCH_NAV_SLOWNESS_FINDINGS_AND_FIX.md +0 -313
- package/src/shared/CometChatUiKit/CometChatUIKit.changes.md +0 -76
- package/src/shared/CometChatUiKit/checkAuthSettings-review.md +0 -211
|
@@ -1958,6 +1958,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
|
|
|
1958
1958
|
});
|
|
1959
1959
|
},
|
|
1960
1960
|
ccCallEnded: ({ call }: any) => {
|
|
1961
|
+
// CometChatIncomingCall emits ccCallEnded with no call when the session ends. The SDK
|
|
1962
|
+
// throws inside getConversationFromMessage(undefined) without rejecting the promise it
|
|
1963
|
+
// returns, so the .catch below never runs and the error surfaces as an unhandled rejection.
|
|
1964
|
+
if (!call) return;
|
|
1961
1965
|
CometChat.CometChatHelper.getConversationFromMessage(call)
|
|
1962
1966
|
.then((conversation) => {
|
|
1963
1967
|
if (!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()) {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
let __listenerIdCounter = 0;
|
|
2
2
|
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
3
|
-
import { Keyboard
|
|
3
|
+
import { Keyboard,
|
|
4
|
+
StatusBar,
|
|
5
|
+
} from "react-native";
|
|
4
6
|
import {
|
|
5
7
|
ColorValue,
|
|
6
8
|
Dimensions,
|
|
7
9
|
ImageSourcePropType,
|
|
8
10
|
ImageStyle,
|
|
9
|
-
InteractionManager,
|
|
10
11
|
KeyboardAvoidingView,
|
|
11
12
|
KeyboardAvoidingViewProps,
|
|
12
13
|
Modal,
|
|
@@ -57,8 +58,10 @@ import {
|
|
|
57
58
|
messageStatus,
|
|
58
59
|
} from "../shared/utils/CometChatMessageHelper";
|
|
59
60
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
61
|
+
import { runAfterInteractions } from "../shared/utils/runAfterInteractions";
|
|
60
62
|
import { applyRawFormatters } from "../shared/formatters/applyRawFormatters";
|
|
61
63
|
import { isCursorWithinMentionRange, getMentionRangeAtCursor } from "../shared/utils/MentionUtils";
|
|
64
|
+
import { insertMentionTokens } from "../shared/utils/mentionTokens";
|
|
62
65
|
import { permissionUtil } from "../shared/utils/PermissionUtil";
|
|
63
66
|
import { CometChatMediaRecorder } from "../shared/views/CometChatMediaRecorder";
|
|
64
67
|
import { useTheme } from "../theme";
|
|
@@ -949,6 +952,19 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
949
952
|
}
|
|
950
953
|
});
|
|
951
954
|
|
|
955
|
+
// Token text the user TYPED is stored escaped (`<@all:…`); it goes back into the
|
|
956
|
+
// input as the literal `<@all:…` they typed. No `user`, so it never enters mentionMap.
|
|
957
|
+
const typedToken = /<(@(?:uid|all):)/g;
|
|
958
|
+
let typedMatch: RegExpExecArray | null;
|
|
959
|
+
while ((typedMatch = typedToken.exec(rawText)) !== null) {
|
|
960
|
+
edits.push({
|
|
961
|
+
startIndex: typedMatch.index,
|
|
962
|
+
endIndex: typedToken.lastIndex,
|
|
963
|
+
replacement: "<" + typedMatch[1],
|
|
964
|
+
user: null,
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
|
|
952
968
|
// Sort edits by startIndex to apply them in order
|
|
953
969
|
edits.sort((a: any, b: any) => a.startIndex - b.startIndex);
|
|
954
970
|
|
|
@@ -966,6 +982,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
966
982
|
edit.replacement +
|
|
967
983
|
rawText.substring(edit.endIndex);
|
|
968
984
|
offset += edit.replacement.length - (edit.endIndex - edit.startIndex);
|
|
985
|
+
if (!edit.user) return; // un-escaped typed text, not a mention
|
|
969
986
|
const rangeKey = `${adjustedStartIndex}_${adjustedStartIndex + edit.replacement.length}`;
|
|
970
987
|
hashMap.set(rangeKey, edit.user);
|
|
971
988
|
});
|
|
@@ -1268,7 +1285,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1268
1285
|
}
|
|
1269
1286
|
|
|
1270
1287
|
if (Platform.OS === "ios" && messageInputRef.current) {
|
|
1271
|
-
|
|
1288
|
+
runAfterInteractions(() => {
|
|
1272
1289
|
let textToProcess = plainTextInput.current;
|
|
1273
1290
|
if (typeof inputMessage === 'string' && inputMessage.trim().length > 0) {
|
|
1274
1291
|
textToProcess = inputMessage;
|
|
@@ -1343,7 +1360,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1343
1360
|
|
|
1344
1361
|
// Clear the TextInput on iOS to remove auto-corrected text
|
|
1345
1362
|
if (Platform.OS === "ios" && messageInputRef.current) {
|
|
1346
|
-
|
|
1363
|
+
runAfterInteractions(() => {
|
|
1347
1364
|
try {
|
|
1348
1365
|
messageInputRef.current?.setNativeProps?.({ text: "" });
|
|
1349
1366
|
messageInputRef.current?.clear?.();
|
|
@@ -2253,24 +2270,9 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
2253
2270
|
}, 100);
|
|
2254
2271
|
};
|
|
2255
2272
|
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
let uidInput = str;
|
|
2261
|
-
|
|
2262
|
-
// Iterate over the array in reverse order
|
|
2263
|
-
entries.forEach(([key, value]) => {
|
|
2264
|
-
let [start, end] = key.split("_").map(Number);
|
|
2265
|
-
|
|
2266
|
-
let pre = uidInput.substring(0, start);
|
|
2267
|
-
let post = uidInput.substring(end);
|
|
2268
|
-
|
|
2269
|
-
uidInput = pre + value.underlyingText + post;
|
|
2270
|
-
});
|
|
2271
|
-
|
|
2272
|
-
return uidInput;
|
|
2273
|
-
};
|
|
2273
|
+
// Picked mentions become their tokens; token-looking text the user typed is escaped so it
|
|
2274
|
+
// is stored — and rendered on every platform — as text, not a live mention.
|
|
2275
|
+
const getRegexString = (str: string) => insertMentionTokens(str, mentionMap.current.entries());
|
|
2274
2276
|
|
|
2275
2277
|
const getPlainString = (
|
|
2276
2278
|
str: string,
|
|
@@ -2425,7 +2427,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
2425
2427
|
mentionMap.current = deletionMentionMap;
|
|
2426
2428
|
|
|
2427
2429
|
const firstStart = overlaps[0].start;
|
|
2428
|
-
|
|
2430
|
+
runAfterInteractions(() => {
|
|
2429
2431
|
messageInputRef.current?.setNativeProps({
|
|
2430
2432
|
selection: { start: firstStart, end: firstStart },
|
|
2431
2433
|
});
|
|
@@ -2606,9 +2608,9 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
2606
2608
|
(item.promptText?.length ?? 0) +
|
|
2607
2609
|
1; // +1 for the space after mention
|
|
2608
2610
|
|
|
2609
|
-
// On iOS,
|
|
2611
|
+
// On iOS, defer so selection is applied after UI updates
|
|
2610
2612
|
if (Platform.OS === "ios") {
|
|
2611
|
-
|
|
2613
|
+
runAfterInteractions(() => {
|
|
2612
2614
|
setSelectionPosition({
|
|
2613
2615
|
start: newCursorPosition,
|
|
2614
2616
|
end: newCursorPosition,
|
|
@@ -2742,8 +2744,13 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
2742
2744
|
{CustomView && CustomView}
|
|
2743
2745
|
</Modal>
|
|
2744
2746
|
<KeyboardAvoidingView
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
+
// "padding" on Android too: with edge-to-edge (always on from RN 0.87 / targetSdk 36) the window no
|
|
2748
|
+
// longer resizes for the keyboard, and "height" squashes this composer instead of lifting it.
|
|
2749
|
+
// When the window does resize (adjustResize), the keyboard overlap is 0 and padding adds nothing.
|
|
2750
|
+
behavior="padding"
|
|
2751
|
+
// The view is measured from its parent, the keyboard from the top of the screen: offset by
|
|
2752
|
+
// what sits above the parent — the top safe area on iOS, the status bar on Android.
|
|
2753
|
+
keyboardVerticalOffset={Platform.select({ ios: kbOffset, android: StatusBar.currentHeight ?? 0 })}
|
|
2747
2754
|
{...keyboardAvoidingViewProps}
|
|
2748
2755
|
>
|
|
2749
2756
|
<View
|
|
@@ -2960,7 +2967,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
2960
2967
|
targetPosition = mentionRange.end;
|
|
2961
2968
|
}
|
|
2962
2969
|
if (targetPosition !== cursorPos) {
|
|
2963
|
-
|
|
2970
|
+
runAfterInteractions(() => {
|
|
2964
2971
|
// Move the cursor IMPERATIVELY — the input is uncontrolled (the `selection`
|
|
2965
2972
|
// prop was removed). A controlled `selection` prop re-fires onSelectionChange
|
|
2966
2973
|
// on every re-render, which hard-freezes iOS once the attachment tray adds
|
|
@@ -70,7 +70,10 @@ import { ChatConfigurator } from "../shared/framework/ChatConfigurator";
|
|
|
70
70
|
import { deepClone, deepMerge } from "../shared/helper/helperFunctions";
|
|
71
71
|
import { Icon, IconName } from "../shared/icons/Icon";
|
|
72
72
|
import { CometChatMessageTemplate } from "../shared/modals/CometChatMessageTemplate";
|
|
73
|
-
import {
|
|
73
|
+
import { messageStatus } from "../shared/utils/CometChatMessageHelper";
|
|
74
|
+
import { groupMemberAddedRows } from "../shared/utils/groupMemberAddedRows";
|
|
75
|
+
import { selectLinkPreview } from "../shared/utils/linkPreviewSelection";
|
|
76
|
+
import { unescapeTypedMentionTokens } from "../shared/utils/mentionTokens";
|
|
74
77
|
import { CommonUtils } from "../shared/utils/CommonUtils";
|
|
75
78
|
import { CometChatBatchMediaContext, BatchMediaResult } from "../shared/utils/batchMediaContext";
|
|
76
79
|
import { CometChatUIKit } from "../shared/CometChatUiKit/CometChatUIKit";
|
|
@@ -965,9 +968,9 @@ export const CometChatMessageList = memo(
|
|
|
965
968
|
});
|
|
966
969
|
|
|
967
970
|
const fileIncoming = deepMerge(incomingBubbleStyles, incomingBubbleStyles.fileBubbleStyles ?? {});
|
|
968
|
-
if (fileIncoming.containerStyle) fileIncoming.containerStyle
|
|
971
|
+
if (fileIncoming.containerStyle) Object.assign(fileIncoming.containerStyle, { height: undefined });
|
|
969
972
|
const fileOutgoing = deepMerge(outgoingBubbleStyles, outgoingBubbleStyles.fileBubbleStyles ?? {});
|
|
970
|
-
if (fileOutgoing.containerStyle) fileOutgoing.containerStyle
|
|
973
|
+
if (fileOutgoing.containerStyle) Object.assign(fileOutgoing.containerStyle, { height: undefined });
|
|
971
974
|
|
|
972
975
|
styleCache.set(MessageTypeConstants.file, {
|
|
973
976
|
incoming: fileIncoming,
|
|
@@ -975,9 +978,9 @@ export const CometChatMessageList = memo(
|
|
|
975
978
|
});
|
|
976
979
|
|
|
977
980
|
const audioIncoming = deepMerge(incomingBubbleStyles, incomingBubbleStyles.audioBubbleStyles ?? {});
|
|
978
|
-
if (audioIncoming.containerStyle) audioIncoming.containerStyle
|
|
981
|
+
if (audioIncoming.containerStyle) Object.assign(audioIncoming.containerStyle, { height: undefined });
|
|
979
982
|
const audioOutgoing = deepMerge(outgoingBubbleStyles, outgoingBubbleStyles.audioBubbleStyles ?? {});
|
|
980
|
-
if (audioOutgoing.containerStyle) audioOutgoing.containerStyle
|
|
983
|
+
if (audioOutgoing.containerStyle) Object.assign(audioOutgoing.containerStyle, { height: undefined });
|
|
981
984
|
|
|
982
985
|
styleCache.set(MessageTypeConstants.audio, {
|
|
983
986
|
incoming: audioIncoming,
|
|
@@ -3581,15 +3584,10 @@ export const CometChatMessageList = memo(
|
|
|
3581
3584
|
message["action"] = "banned";
|
|
3582
3585
|
newMessage(message, false);
|
|
3583
3586
|
},
|
|
3584
|
-
ccGroupMemberAdded: (
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
message["sentAt"] = getUnixTimestamp();
|
|
3589
|
-
message["actionOn"] = user;
|
|
3590
|
-
message["action"] = "added";
|
|
3591
|
-
newMessage(message, false);
|
|
3592
|
-
});
|
|
3587
|
+
ccGroupMemberAdded: (event: any) => {
|
|
3588
|
+
groupMemberAddedRows(event, loggedInUser.current?.getName()).forEach((row) =>
|
|
3589
|
+
newMessage(row, false)
|
|
3590
|
+
);
|
|
3593
3591
|
},
|
|
3594
3592
|
ccGroupMemberKicked: ({ message }: any) => {
|
|
3595
3593
|
message["action"] = "kicked";
|
|
@@ -3846,7 +3844,8 @@ export const CometChatMessageList = memo(
|
|
|
3846
3844
|
}
|
|
3847
3845
|
if (item.getType() === MessageTypeConstants.text) {
|
|
3848
3846
|
let linkData = getExtensionData(item, ExtensionConstants.linkPreview);
|
|
3849
|
-
|
|
3847
|
+
// Same choice as the bubble: no card (e.g. every address is in code) → text style.
|
|
3848
|
+
if (selectLinkPreview(linkData?.links, (item as CometChat.TextMessage).getText())) {
|
|
3850
3849
|
return ExtensionConstants.linkPreview;
|
|
3851
3850
|
}
|
|
3852
3851
|
}
|
|
@@ -4493,7 +4492,7 @@ export const CometChatMessageList = memo(
|
|
|
4493
4492
|
// getPlainString resolves mention tokens but leaves the rich-text wire format alone.
|
|
4494
4493
|
// copyMessageText puts clean plain text on the clipboard for every other app and keeps
|
|
4495
4494
|
// the colour in a private representation our own composer restores on paste.
|
|
4496
|
-
ClipboardPasteHandler.copyMessageText(getPlainString(item["text"], item), textFormatters);
|
|
4495
|
+
ClipboardPasteHandler.copyMessageText(unescapeTypedMentionTokens(getPlainString(item["text"], item)), textFormatters);
|
|
4497
4496
|
// Defer modal dismiss to next frame to avoid Fabric race condition
|
|
4498
4497
|
// where unmounting the Modal while Clipboard is still accessing views
|
|
4499
4498
|
// causes EXC_BAD_ACCESS (SIGSEGV) at null pointer in mount phase.
|
|
@@ -4558,7 +4557,8 @@ export const CometChatMessageList = memo(
|
|
|
4558
4557
|
// The app's own token becomes UI Kit markup BEFORE stripping, the same order the pinned
|
|
4559
4558
|
// panel uses. Without it a consumer's `(#e11d48)text()` reaches the share sheet verbatim.
|
|
4560
4559
|
let strippedText = stripMarkdown(applyRawFormatters(rawText, textFormatters));
|
|
4561
|
-
|
|
4560
|
+
// Tokens become names; typed token text (stored escaped) reads as typed.
|
|
4561
|
+
let textMessage = unescapeTypedMentionTokens(getPlainString(strippedText, messageObject));
|
|
4562
4562
|
let fileUrl = messageObject.getData()["url"];
|
|
4563
4563
|
|
|
4564
4564
|
const getFileName = () => {
|
|
@@ -5819,7 +5819,9 @@ export const CometChatMessageList = memo(
|
|
|
5819
5819
|
onViewableItemsChanged={handleViewableItemsChanged}
|
|
5820
5820
|
// Performance optimizations
|
|
5821
5821
|
windowSize={10}
|
|
5822
|
-
|
|
5822
|
+
// ENG-40210: keep clipping off. On Android it attaches/detaches rows outside Fabric's
|
|
5823
|
+
// mount queue and crashes (addViewAt IndexOutOfBounds), after a push tap and on plain launch.
|
|
5824
|
+
removeClippedSubviews={false}
|
|
5823
5825
|
maxToRenderPerBatch={5}
|
|
5824
5826
|
updateCellsBatchingPeriod={100}
|
|
5825
5827
|
initialNumToRender={15}
|
|
@@ -58,7 +58,8 @@ const dispatchCommand = (
|
|
|
58
58
|
) => {
|
|
59
59
|
const viewTag = findNodeHandle(ref.current);
|
|
60
60
|
if (viewTag != null) {
|
|
61
|
-
|
|
61
|
+
// Newer RN typings declare commandID as number only; the native side accepts command names.
|
|
62
|
+
UIManager.dispatchViewManagerCommand(viewTag, command as unknown as number, args);
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
65
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useReducer, useRef, useState, useMemo, JSX } from 'react';
|
|
2
|
-
import { View, TextInput, TouchableOpacity, Text, Image, ImageBackground, FlatList, ImageSourcePropType, StyleSheet } from 'react-native';
|
|
2
|
+
import { View, TextInput, TouchableOpacity, Text, Image, ImageBackground, FlatList, ImageSourcePropType, StyleSheet, Platform } from 'react-native';
|
|
3
3
|
import { CometChat } from '@cometchat/chat-sdk-react-native';
|
|
4
4
|
import {
|
|
5
5
|
CometChatAvatar,
|
|
@@ -18,6 +18,8 @@ import { deepMerge } from '../shared/helper/helperFunctions';
|
|
|
18
18
|
import { DeepPartial } from '../shared/helper/types';
|
|
19
19
|
import { getCometChatTranslation } from '../shared/resources/CometChatLocalizeNew/LocalizationManager';
|
|
20
20
|
import { CommonUtils } from '../shared/utils/CommonUtils';
|
|
21
|
+
import { selectLinkPreview } from "../shared/utils/linkPreviewSelection";
|
|
22
|
+
import { unescapeTypedMentionTokens } from "../shared/utils/mentionTokens";
|
|
21
23
|
import { stripMarkdown } from '../shared/utils/MarkdownUtils';
|
|
22
24
|
import { CometChatRichTextFormatter } from '../shared/formatters/CometChatRichTextFormatter';
|
|
23
25
|
import { CometChatTextFormatter } from '../shared/formatters/CometChatTextFormatter';
|
|
@@ -62,6 +64,9 @@ const formatPreviewText = (
|
|
|
62
64
|
console.log(e)
|
|
63
65
|
}
|
|
64
66
|
|
|
67
|
+
// Tokens are resolved above; typed token text (stored escaped) now reads as typed.
|
|
68
|
+
text = unescapeTypedMentionTokens(text);
|
|
69
|
+
|
|
65
70
|
return searchRichTextFormatter.getFormattedText(text) ?? text;
|
|
66
71
|
};
|
|
67
72
|
|
|
@@ -761,7 +766,7 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
761
766
|
const theme = useTheme();
|
|
762
767
|
const errorHandler = useCometChatErrorHandler(onError);
|
|
763
768
|
const timeoutIdRef = useRef<any | null>(null);
|
|
764
|
-
const searchInputRef = useRef<TextInput
|
|
769
|
+
const searchInputRef = useRef<React.ComponentRef<typeof TextInput>>(null);
|
|
765
770
|
|
|
766
771
|
// Merge theme styles with provided style overrides
|
|
767
772
|
const mergedStyles = useMemo(() => {
|
|
@@ -1646,8 +1651,8 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1646
1651
|
const metadata = textMessage.getMetadata();
|
|
1647
1652
|
const linkPreview = metadata && (metadata as any)['@injected'] && (metadata as any)['@injected']['extensions'] && (metadata as any)['@injected']['extensions']['link-preview'];
|
|
1648
1653
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1654
|
+
const firstLink = selectLinkPreview(linkPreview?.links, textMessage.getText());
|
|
1655
|
+
if (firstLink) {
|
|
1651
1656
|
const thumbnailUrl = firstLink.image || firstLink.favicon;
|
|
1652
1657
|
|
|
1653
1658
|
if (thumbnailUrl) {
|
|
@@ -2011,7 +2016,7 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
2011
2016
|
initialNumToRender={10}
|
|
2012
2017
|
maxToRenderPerBatch={10}
|
|
2013
2018
|
windowSize={10}
|
|
2014
|
-
removeClippedSubviews={
|
|
2019
|
+
removeClippedSubviews={Platform.OS !== 'android'} // ENG-40210: clipping crashes Fabric on Android
|
|
2015
2020
|
updateCellsBatchingPeriod={100}
|
|
2016
2021
|
onEndReached={() => {
|
|
2017
2022
|
// Load more messages if we're at the end and messages section is visible
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
2
|
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
-
import { ActivityIndicator, View } from "react-native";
|
|
3
|
+
import { ActivityIndicator, LayoutChangeEvent, View } from "react-native";
|
|
4
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
5
|
import { CallingPackage } from "../CallingPackage";
|
|
5
6
|
import { useTheme } from "../../theme";
|
|
6
7
|
import { JSX } from "react";
|
|
@@ -9,6 +10,9 @@ const { Proximity } = NativeModules;
|
|
|
9
10
|
|
|
10
11
|
const CometChatCalls = CallingPackage.CometChatCalls;
|
|
11
12
|
|
|
13
|
+
/** How long the call area must keep the same size before the Calls SDK is mounted into it. */
|
|
14
|
+
const CALL_AREA_SETTLE_MS = 150;
|
|
15
|
+
|
|
12
16
|
/**
|
|
13
17
|
* Props for the CometChatOngoingCall component.
|
|
14
18
|
*
|
|
@@ -88,22 +92,57 @@ export const CometChatOngoingCall = (props: CometChatOngoingCallInterface): JSX.
|
|
|
88
92
|
};
|
|
89
93
|
}, [callToken]);
|
|
90
94
|
|
|
95
|
+
// Size of the area the Calls SDK draws into, once it has stopped changing.
|
|
96
|
+
const [callArea, setCallArea] = useState<{ width: number; height: number } | null>(null);
|
|
97
|
+
const settleTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
98
|
+
|
|
99
|
+
useEffect(() => () => clearTimeout(settleTimer.current), []);
|
|
100
|
+
|
|
101
|
+
// The Calls SDK saves the size of its FIRST layout in a module-level variable and reuses it
|
|
102
|
+
// for every later call in the app session. Mount it only after this area has settled — the
|
|
103
|
+
// SafeAreaView below applies its padding a frame after the first layout — and hand it a box
|
|
104
|
+
// of exactly that size, so the size it saves is the real one.
|
|
105
|
+
const onCallAreaLayout = (e: LayoutChangeEvent) => {
|
|
106
|
+
const { width, height } = e.nativeEvent.layout;
|
|
107
|
+
clearTimeout(settleTimer.current);
|
|
108
|
+
settleTimer.current = setTimeout(() => {
|
|
109
|
+
setCallArea((prev) =>
|
|
110
|
+
prev && prev.width === width && prev.height === height ? prev : { width, height }
|
|
111
|
+
);
|
|
112
|
+
}, CALL_AREA_SETTLE_MS);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Keep the call inside the safe area: on RN 0.87 Android is edge-to-edge, and a full-screen
|
|
116
|
+
// parent (the accepted CometChatIncomingCall, or the Modal of CometChatOutgoingCall) reaches
|
|
117
|
+
// under the system bars. The native SafeAreaView pads only for the insets it overlaps.
|
|
91
118
|
return (
|
|
92
|
-
<
|
|
93
|
-
{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
119
|
+
<SafeAreaView
|
|
120
|
+
edges={["top", "bottom"]}
|
|
121
|
+
style={{
|
|
122
|
+
height: "100%",
|
|
123
|
+
width: "100%",
|
|
124
|
+
position: "relative",
|
|
125
|
+
backgroundColor: theme.color.background1,
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
<View style={{ flex: 1 }} onLayout={onCallAreaLayout}>
|
|
129
|
+
{(callSettings.current && callToken && callArea && (
|
|
130
|
+
<View style={{ width: callArea.width, height: callArea.height }}>
|
|
131
|
+
<CometChatCalls.Component callSettings={callSettings.current} callToken={callToken} />
|
|
132
|
+
</View>
|
|
133
|
+
)) || (
|
|
134
|
+
<View
|
|
135
|
+
style={{
|
|
136
|
+
justifyContent: "center",
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
height: "100%",
|
|
139
|
+
backgroundColor: "transparent",
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<ActivityIndicator size={"large"} color={theme.color.primary} />
|
|
143
|
+
</View>
|
|
144
|
+
)}
|
|
145
|
+
</View>
|
|
146
|
+
</SafeAreaView>
|
|
108
147
|
);
|
|
109
148
|
};
|
|
@@ -281,13 +281,16 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
281
281
|
visible={isModalVisible}
|
|
282
282
|
onRequestClose={handleModalClose}
|
|
283
283
|
>
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
284
|
+
{/* The connected call handles its own safe area. Rendered outside the SafeAreaView below
|
|
285
|
+
so it gets the same geometry as an accepted incoming call: the Calls SDK keeps the size
|
|
286
|
+
of the first call in the session, so both directions must lay out the same way. */}
|
|
287
|
+
{isCallConnected ? (
|
|
288
|
+
<CometChatOngoingCall
|
|
289
|
+
sessionID={callSessionId.current!}
|
|
290
|
+
callSettingsBuilder={callSettings.current!}
|
|
291
|
+
/>
|
|
292
|
+
) : (
|
|
293
|
+
<SafeAreaView style={{ flex: 1 }}>
|
|
291
294
|
<View style={outgoingCallStyle.containerStyle}>
|
|
292
295
|
{TitleView ? (
|
|
293
296
|
TitleView(call)
|
|
@@ -331,8 +334,8 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface): JS
|
|
|
331
334
|
</TouchableOpacity>
|
|
332
335
|
)}
|
|
333
336
|
</View>
|
|
334
|
-
|
|
335
|
-
|
|
337
|
+
</SafeAreaView>
|
|
338
|
+
)}
|
|
336
339
|
</Modal>
|
|
337
340
|
);
|
|
338
341
|
};
|
|
@@ -109,7 +109,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
109
109
|
if (onPress) {
|
|
110
110
|
onPress();
|
|
111
111
|
} else {
|
|
112
|
-
const opened = await Linking.openURL(link);
|
|
112
|
+
const opened: unknown = await Linking.openURL(link);
|
|
113
113
|
if (!opened) {
|
|
114
114
|
Alert.alert(t("SOMETHING_WRONG"));
|
|
115
115
|
}
|
|
@@ -212,15 +212,18 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
212
212
|
</Text>
|
|
213
213
|
</View>
|
|
214
214
|
</View>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
215
|
+
{/* Only the card that carries the message text gets this padded row; the others would show an empty band. */}
|
|
216
|
+
{ChildView && (
|
|
217
|
+
<View
|
|
218
|
+
style={{
|
|
219
|
+
paddingVertical: theme.spacing.padding.p3,
|
|
220
|
+
paddingHorizontal: style?.bodyStyle?.containerStyle.padding,
|
|
221
|
+
flexShrink: 0,
|
|
222
|
+
}}
|
|
223
|
+
>
|
|
224
|
+
<ChildView />
|
|
225
|
+
</View>
|
|
226
|
+
)}
|
|
224
227
|
</View>
|
|
225
228
|
);
|
|
226
229
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CometChat } from "@cometchat/chat-sdk-react-native";
|
|
2
2
|
import React, { JSX } from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
3
4
|
import { AdditionalParams, MessageBubbleAlignmentType } from "../../shared/base/Types";
|
|
4
5
|
import { DataSource, DataSourceDecorator } from "../../shared/framework";
|
|
5
6
|
import { BubbleStyles, CometChatTheme } from "../../theme/type";
|
|
@@ -8,6 +9,7 @@ import { getExtensionData } from "../ExtensionModerator";
|
|
|
8
9
|
import { LinkPreviewBubble } from "./LinkPreviewBubble";
|
|
9
10
|
import { CometChatUIKit } from "../../shared";
|
|
10
11
|
import { DeepPartial } from "../../shared/helper/types";
|
|
12
|
+
import { previewImage, selectLinkPreviews, trimStrayParens } from "../../shared/utils/linkPreviewSelection";
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Extension decorator for rendering link preview messages.
|
|
@@ -60,35 +62,40 @@ export class LinkPreviewExtensionDecorator extends DataSourceDecorator {
|
|
|
60
62
|
): JSX.Element {
|
|
61
63
|
const loggedInUser = CometChatUIKit.loggedInUser;
|
|
62
64
|
const linkData = getExtensionData(message, ExtensionConstants.linkPreview);
|
|
65
|
+
// One card per link the text goes TO (not every address the server scanned) — like React UI Kit.
|
|
66
|
+
const previews = selectLinkPreviews(linkData?.links, message.getText());
|
|
63
67
|
|
|
64
|
-
if (
|
|
68
|
+
if (previews.length === 0) {
|
|
65
69
|
return super.getTextMessageContentView(message, alignment, theme, additionalParams);
|
|
66
|
-
} else {
|
|
67
|
-
const _style: DeepPartial<BubbleStyles["linkPreviewBubbleStyles"]> =
|
|
68
|
-
message.getSender()?.getUid() === loggedInUser?.getUid()
|
|
69
|
-
? theme.messageListStyles?.outgoingMessageBubbleStyles?.linkPreviewBubbleStyles
|
|
70
|
-
: theme.messageListStyles?.incomingMessageBubbleStyles?.linkPreviewBubbleStyles;
|
|
71
|
-
const { image, favicon, title, url, description } = linkData.links[0];
|
|
72
|
-
const img = image.length === 0 || image === favicon ? "" : image;
|
|
73
|
-
return (
|
|
74
|
-
<LinkPreviewBubble
|
|
75
|
-
link={url}
|
|
76
|
-
description={description}
|
|
77
|
-
image={img}
|
|
78
|
-
favicon={favicon}
|
|
79
|
-
ChildView={() =>
|
|
80
|
-
super.getTextMessageBubble(
|
|
81
|
-
(message as CometChat.TextMessage).getText(),
|
|
82
|
-
message as CometChat.TextMessage,
|
|
83
|
-
alignment,
|
|
84
|
-
theme,
|
|
85
|
-
additionalParams
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
title={title}
|
|
89
|
-
style={_style as CometChatTheme["linkPreviewBubbleStyles"]}
|
|
90
|
-
/>
|
|
91
|
-
);
|
|
92
70
|
}
|
|
71
|
+
const _style: DeepPartial<BubbleStyles["linkPreviewBubbleStyles"]> =
|
|
72
|
+
message.getSender()?.getUid() === loggedInUser?.getUid()
|
|
73
|
+
? theme.messageListStyles?.outgoingMessageBubbleStyles?.linkPreviewBubbleStyles
|
|
74
|
+
: theme.messageListStyles?.incomingMessageBubbleStyles?.linkPreviewBubbleStyles;
|
|
75
|
+
const textView = () =>
|
|
76
|
+
super.getTextMessageBubble(
|
|
77
|
+
(message as CometChat.TextMessage).getText(),
|
|
78
|
+
message as CometChat.TextMessage,
|
|
79
|
+
alignment,
|
|
80
|
+
theme,
|
|
81
|
+
additionalParams
|
|
82
|
+
);
|
|
83
|
+
// Cards stack in link order with a small gap; the message text sits under the last one.
|
|
84
|
+
return (
|
|
85
|
+
<View style={{ gap: theme.spacing.padding.p2 }}>
|
|
86
|
+
{previews.map(({ image, favicon, title, url, description }, i) => (
|
|
87
|
+
<LinkPreviewBubble
|
|
88
|
+
key={`${i}-${url}`}
|
|
89
|
+
link={trimStrayParens(url)}
|
|
90
|
+
description={description}
|
|
91
|
+
image={previewImage(image, favicon)}
|
|
92
|
+
favicon={favicon}
|
|
93
|
+
ChildView={i === previews.length - 1 ? textView : undefined}
|
|
94
|
+
title={title}
|
|
95
|
+
style={_style as CometChatTheme["linkPreviewBubbleStyles"]}
|
|
96
|
+
/>
|
|
97
|
+
))}
|
|
98
|
+
</View>
|
|
99
|
+
);
|
|
93
100
|
}
|
|
94
101
|
}
|
|
@@ -2,7 +2,6 @@ import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
ActivityIndicator,
|
|
4
4
|
FlatList,
|
|
5
|
-
InteractionManager,
|
|
6
5
|
Keyboard,
|
|
7
6
|
KeyboardAvoidingView,
|
|
8
7
|
NativeModules,
|
|
@@ -21,6 +20,7 @@ import { useCometChatTranslation } from "../../shared/resources/CometChatLocaliz
|
|
|
21
20
|
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
|
|
22
21
|
import { CometChatMessageEvents } from "../../shared/events/CometChatMessageEvents";
|
|
23
22
|
import { messageStatus } from "../../shared/utils/CometChatMessageHelper";
|
|
23
|
+
import { runAfterInteractions } from "../../shared/utils/runAfterInteractions";
|
|
24
24
|
|
|
25
25
|
const { CommonUtil } = NativeModules;
|
|
26
26
|
|
|
@@ -147,7 +147,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
147
147
|
const loggedInUser = useRef<CometChat.User | null>(null);
|
|
148
148
|
const theme = useTheme();
|
|
149
149
|
const { t } = useCometChatTranslation();
|
|
150
|
-
const answerRefs = useRef<(TextInput | null)[]>([]);
|
|
150
|
+
const answerRefs = useRef<(React.ComponentRef<typeof TextInput> | null)[]>([]);
|
|
151
151
|
const [lastRemovedIndex, setLastRemovedIndex] = useState<number | null>(null);
|
|
152
152
|
const [newlyAddedIndex, setNewlyAddedIndex] = useState<number | null>(null);
|
|
153
153
|
const flatListRef = useRef<FlatList>(null);
|
|
@@ -425,7 +425,7 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
425
425
|
|
|
426
426
|
useEffect(() => {
|
|
427
427
|
if (answers.length) {
|
|
428
|
-
|
|
428
|
+
runAfterInteractions(() => {
|
|
429
429
|
flatListRef.current?.scrollToEnd({ animated: true });
|
|
430
430
|
});
|
|
431
431
|
}
|
|
@@ -588,10 +588,10 @@ export const CometChatCreatePoll = (props: CometChatCreatePollInterface) => {
|
|
|
588
588
|
style={{
|
|
589
589
|
paddingHorizontal: 20,
|
|
590
590
|
backgroundColor: theme.color.background1,
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
// Both platforms: an edge-to-edge Android window (RN 0.86+ Modals, targetSdk 35+)
|
|
592
|
+
// draws under the navigation bar, so the fixed 10 left Create hidden behind it.
|
|
593
|
+
// Non-edge-to-edge Android reports a 0 inset, so this stays 10 there.
|
|
594
|
+
paddingBottom: Math.max(insets.bottom, 10),
|
|
595
595
|
}}
|
|
596
596
|
>
|
|
597
597
|
{error && <ErrorView />}
|
|
@@ -227,10 +227,10 @@ export const PollsBubble = (props: PollsBubbleInterface) => {
|
|
|
227
227
|
const secondavatarStyle = voteravatarStyle;
|
|
228
228
|
const thirdavatarStyle = voteravatarStyle;
|
|
229
229
|
if (secondavatarStyle && secondavatarStyle.containerStyle) {
|
|
230
|
-
secondavatarStyle.containerStyle
|
|
230
|
+
Object.assign(secondavatarStyle.containerStyle, { marginLeft: -10 });
|
|
231
231
|
}
|
|
232
232
|
if (thirdavatarStyle && thirdavatarStyle.containerStyle) {
|
|
233
|
-
thirdavatarStyle.containerStyle
|
|
233
|
+
Object.assign(thirdavatarStyle.containerStyle, { marginLeft: -10 });
|
|
234
234
|
}
|
|
235
235
|
// Ensure value is a string for rendering
|
|
236
236
|
let optionText = typeof value === 'string' ? value : (value && value.value ? value.value : String(value));
|
package/src/globals.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `__DEV__` is injected by the React Native runtime. React Native's own typings declare it,
|
|
3
|
+
* but only when `react-native` resolves to its generated typings; declare it here so the
|
|
4
|
+
* package's own type-check does not depend on how `react-native` gets resolved.
|
|
5
|
+
*/
|
|
6
|
+
declare const __DEV__: boolean;
|