@cometchat/chat-uikit-react-native 5.4.1 → 5.5.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/android/src/main/java/com/reactnativecometchatuikit/CometChatClipboardModule.kt +34 -0
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +562 -5
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorViewManager.kt +28 -1
- package/ios/CometChatClipboardModule.m +5 -0
- package/ios/CometChatClipboardModule.swift +22 -0
- package/ios/RichTextEditorView.swift +636 -31
- package/ios/RichTextEditorViewManager.m +3 -0
- package/ios/RichTextEditorViewManager.swift +24 -0
- package/package.json +5 -2
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +283 -64
- package/src/CometChatCompactMessageComposer/index.ts +2 -0
- package/src/CometChatConversations/CometChatConversations.tsx +299 -15
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +2 -2
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +15 -3
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +181 -12
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +10 -1
- package/src/CometChatMessageList/CometChatMessageList.tsx +572 -16
- package/src/CometChatMessageList/components/MessageModals.tsx +30 -0
- package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +21 -9
- package/src/CometChatMessageList/components/MessageQuickActions.tsx +162 -0
- package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +964 -0
- package/src/CometChatPinnedMessages/index.ts +5 -0
- package/src/CometChatPinnedMessages/style.ts +216 -0
- package/src/CometChatRichTextEditor/RichTextEditorViewNativeComponent.ts +5 -0
- package/src/CometChatRichTextEditor/index.tsx +31 -1
- package/src/CometChatRichTextEditor/types.ts +21 -1
- package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +871 -0
- package/src/CometChatSavedMessages/index.ts +5 -0
- package/src/CometChatSavedMessages/style.ts +159 -0
- package/src/CometChatSearch/CometChatSearch.tsx +71 -341
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +22 -2
- package/src/index.ts +60 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +18 -1
- package/src/shared/base/Types.ts +5 -0
- package/src/shared/constants/UIKitConstants.ts +16 -17
- package/src/shared/constants/textPatterns.ts +27 -0
- package/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +25 -225
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +37 -0
- package/src/shared/events/ListenerInitializer.ts +20 -1
- package/src/shared/events/messages.ts +18 -0
- package/src/shared/formatters/CometChatRichTextFormatter/index.tsx +123 -25
- package/src/shared/formatters/CometChatTextFormatter.ts +22 -0
- package/src/shared/formatters/applyRawFormatters.ts +31 -0
- package/src/shared/formatters/index.ts +14 -0
- package/src/shared/formatters/richTextWireFormat.ts +165 -0
- package/src/shared/framework/MessageDataSource.tsx +309 -10
- package/src/shared/icons/components/thread-follow.tsx +13 -0
- package/src/shared/icons/components/thread-unfollow.tsx +13 -0
- package/src/shared/icons/components/unsave.tsx +13 -0
- package/src/shared/icons/icon-mapping.tsx +6 -0
- package/src/shared/index.ts +37 -0
- package/src/shared/resources/CometChatLocalizeNew/CometChatI18nProvider.tsx +15 -30
- package/src/shared/resources/CometChatLocalizeNew/CometChatLocalizationHelper.ts +138 -19
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +74 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +54 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +54 -1
- package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +11 -0
- package/src/shared/utils/MarkdownUtils.ts +57 -6
- package/src/shared/utils/MessageUtils.tsx +80 -5
- package/src/shared/utils/PinConversationHelper.ts +245 -0
- package/src/shared/utils/PinSaveFeatureGates.ts +178 -0
- package/src/shared/utils/PinSaveHelper.ts +549 -0
- package/src/shared/utils/PinnedMessagesHelper.ts +65 -0
- package/src/shared/utils/SavedMessagesHelper.ts +267 -0
- package/src/shared/utils/ThreadSubscriptionHelper.ts +427 -0
- package/src/shared/utils/__testUtils__/messagesRequestBuilderMock.ts +37 -0
- package/src/shared/utils/cloneRequestBuilder.ts +25 -0
- package/src/shared/utils/conversationUtils.ts +8 -1
- package/src/shared/utils/stripRichText.ts +7 -0
- package/src/shared/views/ClipboardPasteHandler/ClipboardPasteHandler.ts +32 -0
- package/src/shared/views/ClipboardPasteHandler/NativeCometChatClipboardModule.ts +6 -0
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +4 -0
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +5 -0
- package/src/shared/views/CometChatAvatar/CometChatAvatar.tsx +17 -5
- package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +5 -1
- package/src/shared/views/CometChatCaptionText/CometChatCaptionText.tsx +8 -1
- package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +2 -0
- package/src/shared/views/CometChatConversationStarter/CometChatConversationStarter.tsx +91 -20
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +5 -0
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +5 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +6 -1
- package/src/shared/views/CometChatList/Header.tsx +8 -2
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +4 -0
- package/src/shared/views/CometChatRetryButton/CometChatRetryButton.tsx +1 -0
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +4 -0
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +5 -0
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +5 -0
- package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +4 -1
- package/src/theme/default/default.ts +6 -0
- package/src/theme/type.ts +4 -0
|
@@ -169,6 +169,7 @@ const CometChatBottomSheet = forwardRef(
|
|
|
169
169
|
>
|
|
170
170
|
{/* Animated overlay that fades in from transparent to a semi-transparent black */}
|
|
171
171
|
<Animated.View
|
|
172
|
+
testID='BottomSheet.overlay'
|
|
172
173
|
style={{
|
|
173
174
|
flex: 1,
|
|
174
175
|
backgroundColor: overlayAnim.interpolate({
|
|
@@ -207,7 +208,10 @@ const CometChatBottomSheet = forwardRef(
|
|
|
207
208
|
>
|
|
208
209
|
<View
|
|
209
210
|
style={{
|
|
210
|
-
|
|
211
|
+
// Content-sized sheets must still shrink to the sheet's maxHeight: without
|
|
212
|
+
// flexShrink this view keeps its full content height and overflows past the
|
|
213
|
+
// bottom of the screen, leaving the last rows of a scrollable child unreachable.
|
|
214
|
+
...(doNotOccupyEntireHeight ? { flexShrink: 1 } : { flex: 1 }),
|
|
211
215
|
paddingBottom: style.paddingBottom ?? 0,
|
|
212
216
|
}}
|
|
213
217
|
>
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
CometChatUrlsFormatter,
|
|
11
11
|
CometChatRichTextFormatter,
|
|
12
12
|
} from "../../formatters";
|
|
13
|
+
import { applyRawFormatters } from "../../formatters/applyRawFormatters";
|
|
13
14
|
import { CommonUtils } from "../../utils/CommonUtils";
|
|
14
15
|
import { CometChatUIKit } from "../../CometChatUiKit";
|
|
15
16
|
import { MentionsTargetElement } from "../../constants/UIKitConstants";
|
|
@@ -46,9 +47,15 @@ export function CometChatCaptionText({
|
|
|
46
47
|
() => buildCaptionFormatters(message, theme, additionalParams),
|
|
47
48
|
[message, theme, additionalParams]
|
|
48
49
|
);
|
|
50
|
+
// A consumer's own wire token becomes UI Kit markup before the chain above parses the caption —
|
|
51
|
+
// same order the text bubble uses, so a caption and a text message render identically.
|
|
52
|
+
const text = useMemo(
|
|
53
|
+
() => applyRawFormatters(caption, additionalParams?.textFormatters),
|
|
54
|
+
[caption, additionalParams]
|
|
55
|
+
);
|
|
49
56
|
return (
|
|
50
57
|
<CometChatTextBubble
|
|
51
|
-
text={
|
|
58
|
+
text={text}
|
|
52
59
|
textStyle={textStyle}
|
|
53
60
|
textContainerStyle={containerStyle}
|
|
54
61
|
textFormatters={formatters}
|
|
@@ -154,6 +154,7 @@ export const CometChatConfirmDialog = (props: CometChatConfirmDialogInterface) =
|
|
|
154
154
|
)}
|
|
155
155
|
<View style={styles.buttonContainer}>
|
|
156
156
|
<TouchableOpacity
|
|
157
|
+
testID='ConfirmDialog.cancel'
|
|
157
158
|
style={[theme.confirmDialogStyles.cancelButtonStyle, cancelButtonStyle]}
|
|
158
159
|
onPress={(e) => {
|
|
159
160
|
e.stopPropagation();
|
|
@@ -165,6 +166,7 @@ export const CometChatConfirmDialog = (props: CometChatConfirmDialogInterface) =
|
|
|
165
166
|
</Text>
|
|
166
167
|
</TouchableOpacity>
|
|
167
168
|
<TouchableOpacity
|
|
169
|
+
testID='ConfirmDialog.confirm'
|
|
168
170
|
style={[theme.confirmDialogStyles.confirmButtonStyle, confirmButtonStyle]}
|
|
169
171
|
onPress={(e) => {
|
|
170
172
|
e.stopPropagation();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { Component, ReactNode, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Animated,
|
|
4
4
|
ScrollView,
|
|
@@ -8,21 +8,39 @@ import {
|
|
|
8
8
|
View,
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import { useTheme } from '../../../theme';
|
|
11
|
-
import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
12
11
|
|
|
13
12
|
export interface CometChatConversationStarterProps {
|
|
14
13
|
getConversationStarters: () => Promise<string[]>;
|
|
15
14
|
onSuggestionClicked?: (reply: string) => void;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
// No 'error' member: a failure is indistinguishable from 'nothing to suggest', and both
|
|
18
|
+
// render null. See the catch below for why an error must never reach the screen.
|
|
19
|
+
type State = 'loading' | 'loaded' | 'empty';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Is this rejection "your plan does not include AI", rather than something a retry could fix?
|
|
23
|
+
*
|
|
24
|
+
* Matched on the code first; the message is a fallback because the same refusal reaches
|
|
25
|
+
* different SDK surfaces with the code sometimes nested on the response rather than the
|
|
26
|
+
* exception.
|
|
27
|
+
*/
|
|
28
|
+
export const isFeatureUnavailable = (error: any): boolean => {
|
|
29
|
+
try {
|
|
30
|
+
const code = error?.code ?? error?.error?.code ?? '';
|
|
31
|
+
if (code === 'ERR_FEATURE_NOT_ACCESSIBLE') return true;
|
|
32
|
+
const message = String(error?.message ?? error?.error?.message ?? '');
|
|
33
|
+
return /feature is not available|upgrade your plan/i.test(message);
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
19
38
|
|
|
20
39
|
const CometChatConversationStarter: React.FC<CometChatConversationStarterProps> = ({
|
|
21
40
|
getConversationStarters,
|
|
22
41
|
onSuggestionClicked,
|
|
23
42
|
}) => {
|
|
24
43
|
const theme = useTheme();
|
|
25
|
-
const { t } = useCometChatTranslation();
|
|
26
44
|
const [state, setState] = useState<State>('loading');
|
|
27
45
|
const [starters, setStarters] = useState<string[]>([]);
|
|
28
46
|
const shimmer = useRef(new Animated.Value(0.4)).current;
|
|
@@ -45,7 +63,30 @@ const CometChatConversationStarter: React.FC<CometChatConversationStarterProps>
|
|
|
45
63
|
setState('empty');
|
|
46
64
|
}
|
|
47
65
|
})
|
|
48
|
-
.catch(() =>
|
|
66
|
+
.catch((error: any) => {
|
|
67
|
+
// Starters are SUGGESTIONS. They are not the conversation, and nothing about the
|
|
68
|
+
// conversation depends on them, so a failure here must never put anything on screen —
|
|
69
|
+
// it renders nothing and the chat is left exactly as it would have been.
|
|
70
|
+
//
|
|
71
|
+
// It used to render "Could not load conversation starters. Please try again.", which was
|
|
72
|
+
// wrong twice over: on an app without the AI add-on the call returns the same 403 for
|
|
73
|
+
// ever, so the retry is a instruction that can never be satisfied; and because this view
|
|
74
|
+
// stood in for the whole empty state, that one line was the only thing on an empty
|
|
75
|
+
// conversation — it read as "the chat failed to load".
|
|
76
|
+
//
|
|
77
|
+
// Logged rather than swallowed, so a genuine outage is still diagnosable from the
|
|
78
|
+
// console. The two cases are logged differently on purpose: a missing add-on is expected
|
|
79
|
+
// and should not look like a defect to an integrator reading their logs.
|
|
80
|
+
if (isFeatureUnavailable(error)) {
|
|
81
|
+
console.warn(
|
|
82
|
+
'[CometChatConversationStarter] AI conversation starters are not enabled for this app; ' +
|
|
83
|
+
'no starters will be shown. This is a plan setting, not an error.'
|
|
84
|
+
);
|
|
85
|
+
} else {
|
|
86
|
+
console.error('[CometChatConversationStarter] Failed to load conversation starters', error);
|
|
87
|
+
}
|
|
88
|
+
setState('empty');
|
|
89
|
+
})
|
|
49
90
|
.finally(() => loop.stop());
|
|
50
91
|
|
|
51
92
|
return () => loop.stop();
|
|
@@ -63,14 +104,6 @@ const CometChatConversationStarter: React.FC<CometChatConversationStarterProps>
|
|
|
63
104
|
);
|
|
64
105
|
}
|
|
65
106
|
|
|
66
|
-
if (state === 'error') {
|
|
67
|
-
return (
|
|
68
|
-
<View style={s.container}>
|
|
69
|
-
<Text style={s.stateText}>{t('ai_conversation_starter_error')}</Text>
|
|
70
|
-
</View>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
107
|
if (state === 'empty') {
|
|
75
108
|
return null;
|
|
76
109
|
}
|
|
@@ -130,12 +163,50 @@ const styles = (theme: ReturnType<typeof useTheme>) =>
|
|
|
130
163
|
fontSize: theme.typography.body.regular.fontSize,
|
|
131
164
|
fontFamily: theme.typography.body.regular.fontFamily,
|
|
132
165
|
},
|
|
133
|
-
stateText: {
|
|
134
|
-
color: theme.color.textSecondary,
|
|
135
|
-
fontSize: theme.typography.caption1.regular.fontSize,
|
|
136
|
-
fontFamily: theme.typography.caption1.regular.fontFamily,
|
|
137
|
-
paddingHorizontal: 4,
|
|
138
|
-
},
|
|
139
166
|
});
|
|
140
167
|
|
|
141
|
-
|
|
168
|
+
/**
|
|
169
|
+
* A crash in the suggestions must never take the conversation with it.
|
|
170
|
+
*
|
|
171
|
+
* The promise path is already handled — a rejected fetch logs and renders nothing. This covers
|
|
172
|
+
* the other half: an exception thrown while RENDERING. React unmounts the nearest tree when a
|
|
173
|
+
* render throws, and this component is mounted INSIDE the message list, so without a boundary a
|
|
174
|
+
* fault in an optional AI add-on would blank the whole conversation. That is the wrong failure
|
|
175
|
+
* for a feature whose entire job is to suggest an opening line.
|
|
176
|
+
*
|
|
177
|
+
* Renders null on failure, exactly like having no suggestions, so the chat is left as if the
|
|
178
|
+
* feature were not enabled at all.
|
|
179
|
+
*/
|
|
180
|
+
class ConversationStarterBoundary extends Component<
|
|
181
|
+
{ children: ReactNode },
|
|
182
|
+
{ failed: boolean }
|
|
183
|
+
> {
|
|
184
|
+
state = { failed: false };
|
|
185
|
+
|
|
186
|
+
static getDerivedStateFromError() {
|
|
187
|
+
return { failed: true };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
componentDidCatch(error: Error) {
|
|
191
|
+
console.error(
|
|
192
|
+
'[CometChatConversationStarter] Suggestions crashed and were dropped; the conversation is unaffected',
|
|
193
|
+
error
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
render() {
|
|
198
|
+
return this.state.failed ? null : this.props.children;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Exported already wrapped, so every call site is protected by construction rather than by each
|
|
204
|
+
* one remembering to add a boundary.
|
|
205
|
+
*/
|
|
206
|
+
const SafeCometChatConversationStarter: React.FC<CometChatConversationStarterProps> = (props) => (
|
|
207
|
+
<ConversationStarterBoundary>
|
|
208
|
+
<CometChatConversationStarter {...props} />
|
|
209
|
+
</ConversationStarterBoundary>
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
export default SafeCometChatConversationStarter;
|
|
@@ -18,6 +18,7 @@ import { useCometChatTranslation } from '../../resources/CometChatLocalizeNew';
|
|
|
18
18
|
import { groupAttachments } from '../../utils/groupAttachments';
|
|
19
19
|
import { CometChatUIKit } from '../../CometChatUiKit';
|
|
20
20
|
import { CometChatCaptionText } from '../CometChatCaptionText';
|
|
21
|
+
import { AdditionalParams } from "../../base/Types";
|
|
21
22
|
|
|
22
23
|
const { FileManager } = NativeModules;
|
|
23
24
|
const fileEventEmitter = new NativeEventEmitter(FileManager);
|
|
@@ -53,6 +54,8 @@ export interface CometChatFilesBubbleProps {
|
|
|
53
54
|
/** Per-instance style overrides (applied over the tokenized defaults) — same pattern as the
|
|
54
55
|
* other bubbles (e.g. CometChatAudioBubble / CometChatFileBubble). */
|
|
55
56
|
style?: CometChatTheme["filesBubbleStyles"];
|
|
57
|
+
/** Render-time params from the message list — carries the consumer's `textFormatters`. */
|
|
58
|
+
additionalParams?: AdditionalParams;
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
/**
|
|
@@ -64,6 +67,7 @@ export function CometChatFilesBubble({
|
|
|
64
67
|
message,
|
|
65
68
|
theme,
|
|
66
69
|
style,
|
|
70
|
+
additionalParams,
|
|
67
71
|
}: CometChatFilesBubbleProps) {
|
|
68
72
|
const { t } = useCometChatTranslation();
|
|
69
73
|
const compTheme = useCompTheme();
|
|
@@ -298,6 +302,7 @@ export function CometChatFilesBubble({
|
|
|
298
302
|
{Boolean(caption) && (
|
|
299
303
|
<CometChatCaptionText
|
|
300
304
|
message={message}
|
|
305
|
+
additionalParams={additionalParams}
|
|
301
306
|
caption={caption}
|
|
302
307
|
theme={theme}
|
|
303
308
|
containerStyle={{
|
|
@@ -11,6 +11,7 @@ import { CometChatMediaViewer } from '../CometChatMediaViewer';
|
|
|
11
11
|
import { CometChatCaptionText } from '../CometChatCaptionText';
|
|
12
12
|
import { Icon } from '../../icons/Icon';
|
|
13
13
|
import { isImageMime } from '../CometChatMediaViewer/mediaViewerUtils';
|
|
14
|
+
import { AdditionalParams } from "../../base/Types";
|
|
14
15
|
|
|
15
16
|
// ---------------------------------------------------------------------------
|
|
16
17
|
// Design doc §8.1 — ImagesBubble: renders a single-kind IMAGE message (all images after the §7 fan-out)
|
|
@@ -211,6 +212,8 @@ export interface CometChatImagesBubbleProps {
|
|
|
211
212
|
theme: CometChatTheme;
|
|
212
213
|
/** Per-instance style overrides — shares the `mediaGridBubbleStyles` theme key with VideosBubble. */
|
|
213
214
|
style?: CometChatTheme["mediaGridBubbleStyles"];
|
|
215
|
+
/** Render-time params from the message list — carries the consumer's `textFormatters`. */
|
|
216
|
+
additionalParams?: AdditionalParams;
|
|
214
217
|
}
|
|
215
218
|
|
|
216
219
|
/**
|
|
@@ -221,6 +224,7 @@ export function CometChatImagesBubble({
|
|
|
221
224
|
message: initialMessage,
|
|
222
225
|
theme,
|
|
223
226
|
style,
|
|
227
|
+
additionalParams,
|
|
224
228
|
}: CometChatImagesBubbleProps) {
|
|
225
229
|
const compTheme = useCompTheme();
|
|
226
230
|
const s = deepMerge(theme.mediaGridBubbleStyles ?? {}, compTheme.mediaGridBubbleStyles ?? {}, style ?? {});
|
|
@@ -287,6 +291,7 @@ export function CometChatImagesBubble({
|
|
|
287
291
|
{Boolean(caption) && (
|
|
288
292
|
<CometChatCaptionText
|
|
289
293
|
message={message}
|
|
294
|
+
additionalParams={additionalParams}
|
|
290
295
|
caption={caption}
|
|
291
296
|
theme={theme}
|
|
292
297
|
containerStyle={{
|
|
@@ -423,7 +423,12 @@ export const CometChatList = React.forwardRef<CometChatListActionsInterface, Com
|
|
|
423
423
|
if (position !== undefined) {
|
|
424
424
|
if (position === 0) return [item, ...prev];
|
|
425
425
|
if (position >= prev.length) return [...prev, item];
|
|
426
|
-
|
|
426
|
+
// slice(0, position), NOT position - 1. The old form dropped the element
|
|
427
|
+
// immediately before the insert point: inserting at 2 in a 5-item list
|
|
428
|
+
// produced [0, item, 2, 3, 4] — index 1 silently deleted. Every other
|
|
429
|
+
// caller passes 0, which takes the branch above, so this went unnoticed
|
|
430
|
+
// until the conversation-pin reordering became the first middle insert.
|
|
431
|
+
return [...prev.slice(0, position), item, ...prev.slice(position)];
|
|
427
432
|
}
|
|
428
433
|
return [...prev, item];
|
|
429
434
|
});
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
ViewStyle,
|
|
13
13
|
} from "react-native";
|
|
14
14
|
import { useTheme } from "../../../theme";
|
|
15
|
+
import { useCometChatTranslation } from "../../resources/CometChatLocalizeNew";
|
|
15
16
|
import { Icon } from "../../icons/Icon";
|
|
16
17
|
import styles from "./styles";
|
|
17
18
|
|
|
@@ -163,7 +164,7 @@ export default function Header({
|
|
|
163
164
|
titleStyle = {},
|
|
164
165
|
titleViewStyle,
|
|
165
166
|
containerStyle,
|
|
166
|
-
searchPlaceholderText
|
|
167
|
+
searchPlaceholderText,
|
|
167
168
|
confirmSelectionStyle,
|
|
168
169
|
selectionCancelStyle,
|
|
169
170
|
titleSeparatorStyle = {},
|
|
@@ -174,7 +175,11 @@ export default function Header({
|
|
|
174
175
|
onSearchBarClicked,
|
|
175
176
|
}: HeaderProps) {
|
|
176
177
|
const theme = useTheme();
|
|
178
|
+
const { t } = useCometChatTranslation();
|
|
177
179
|
const inputRef = useRef<TextInput>(null);
|
|
180
|
+
// Callers that pass nothing used to get a hardcoded English "Search", which
|
|
181
|
+
// is why the conversation list's search box stayed English in every locale.
|
|
182
|
+
const searchPlaceholder = searchPlaceholderText ?? t("SEARCH");
|
|
178
183
|
return (
|
|
179
184
|
<View style={[styles.listBaseHeaderStyle, { width: '100%' }]}>
|
|
180
185
|
{/* Header section with border */}
|
|
@@ -277,6 +282,7 @@ export default function Header({
|
|
|
277
282
|
) : (
|
|
278
283
|
|
|
279
284
|
<Pressable
|
|
285
|
+
testID='List.searchBar'
|
|
280
286
|
onPress={onSearchBarClicked}
|
|
281
287
|
disabled={!onSearchBarClicked}
|
|
282
288
|
>
|
|
@@ -309,7 +315,7 @@ export default function Header({
|
|
|
309
315
|
/>
|
|
310
316
|
<TextInput
|
|
311
317
|
ref={inputRef}
|
|
312
|
-
placeholder={
|
|
318
|
+
placeholder={searchPlaceholder}
|
|
313
319
|
placeholderTextColor={
|
|
314
320
|
searchStyle?.placehodlerTextStyle?.color || theme.color.textTertiary
|
|
315
321
|
}
|
|
@@ -21,6 +21,8 @@ import { Style } from "./style";
|
|
|
21
21
|
import { DeepPartial } from "../../helper/types";
|
|
22
22
|
|
|
23
23
|
export interface CometChatListItemInterface {
|
|
24
|
+
/** Forwarded to the row's root node so a caller can address a specific row. */
|
|
25
|
+
testID?: string;
|
|
24
26
|
/**
|
|
25
27
|
* Unique identifier for the list item.
|
|
26
28
|
*/
|
|
@@ -116,6 +118,7 @@ export const CometChatListItem = React.memo((props: CometChatListItemInterface)
|
|
|
116
118
|
const theme = useTheme();
|
|
117
119
|
|
|
118
120
|
const {
|
|
121
|
+
testID,
|
|
119
122
|
id,
|
|
120
123
|
avatarURL,
|
|
121
124
|
avatarName,
|
|
@@ -269,6 +272,7 @@ export const CometChatListItem = React.memo((props: CometChatListItemInterface)
|
|
|
269
272
|
return (
|
|
270
273
|
<ListComponent
|
|
271
274
|
{...listComponentProps}
|
|
275
|
+
testID={testID}
|
|
272
276
|
style={[containerStyle, selected && { backgroundColor: theme.color.background4 }]}
|
|
273
277
|
>
|
|
274
278
|
{getLeadingView()}
|
|
@@ -68,6 +68,10 @@ export const CometChatSuggestionList = (props: CometChatSuggestionListInterface)
|
|
|
68
68
|
return (
|
|
69
69
|
<CometChatListItem
|
|
70
70
|
key={index}
|
|
71
|
+
// Derived from the suggestion's own id so a test can pick ONE row out of a list that
|
|
72
|
+
// is virtualized and reorders as you type. A plain shared id would force atIndex(),
|
|
73
|
+
// which picks an unpredictable row.
|
|
74
|
+
testID={`SuggestionList.item-${item.id}`}
|
|
71
75
|
id={item.id}
|
|
72
76
|
title={isAllAlias ? undefined : item.name}
|
|
73
77
|
TitleView={TitleView}
|
|
@@ -12,6 +12,7 @@ import { CometChatMessageEvents } from '../../events/CometChatMessageEvents';
|
|
|
12
12
|
import { CometChatMediaViewer } from '../CometChatMediaViewer';
|
|
13
13
|
import { CometChatCaptionText } from '../CometChatCaptionText';
|
|
14
14
|
import { isVideoMime } from '../CometChatMediaViewer/mediaViewerUtils';
|
|
15
|
+
import { AdditionalParams } from "../../base/Types";
|
|
15
16
|
|
|
16
17
|
// ---------------------------------------------------------------------------
|
|
17
18
|
// Design doc §8.1 — VideosBubble: renders a single-kind VIDEO message (all videos after the §7 fan-out)
|
|
@@ -309,6 +310,8 @@ export interface CometChatVideosBubbleProps {
|
|
|
309
310
|
theme: CometChatTheme;
|
|
310
311
|
/** Per-instance style overrides — shares the `mediaGridBubbleStyles` theme key with ImagesBubble. */
|
|
311
312
|
style?: CometChatTheme["mediaGridBubbleStyles"];
|
|
313
|
+
/** Render-time params from the message list — carries the consumer's `textFormatters`. */
|
|
314
|
+
additionalParams?: AdditionalParams;
|
|
312
315
|
}
|
|
313
316
|
|
|
314
317
|
/**
|
|
@@ -319,6 +322,7 @@ export function CometChatVideosBubble({
|
|
|
319
322
|
message: initialMessage,
|
|
320
323
|
theme,
|
|
321
324
|
style,
|
|
325
|
+
additionalParams,
|
|
322
326
|
}: CometChatVideosBubbleProps) {
|
|
323
327
|
const compTheme = useCompTheme();
|
|
324
328
|
const s = deepMerge(theme.mediaGridBubbleStyles ?? {}, compTheme.mediaGridBubbleStyles ?? {}, style ?? {});
|
|
@@ -402,6 +406,7 @@ export function CometChatVideosBubble({
|
|
|
402
406
|
{Boolean(caption) && (
|
|
403
407
|
<CometChatCaptionText
|
|
404
408
|
message={message}
|
|
409
|
+
additionalParams={additionalParams}
|
|
405
410
|
caption={caption}
|
|
406
411
|
theme={theme}
|
|
407
412
|
containerStyle={{
|
|
@@ -8,6 +8,7 @@ import { CometChatAudioBubble } from '../CometChatAudioBubble';
|
|
|
8
8
|
import { CometChatCaptionText } from '../CometChatCaptionText';
|
|
9
9
|
import { deepMerge } from '../../helper/helperFunctions';
|
|
10
10
|
import { useCompTheme } from '../../../theme/hook';
|
|
11
|
+
import { AdditionalParams } from "../../base/Types";
|
|
11
12
|
|
|
12
13
|
// ---------------------------------------------------------------------------
|
|
13
14
|
// Design doc §8.1a — the "VoiceNoteBubble": renders a RECORDED voice-note message
|
|
@@ -23,6 +24,8 @@ export interface CometChatVoiceNoteBubbleProps {
|
|
|
23
24
|
theme: CometChatTheme;
|
|
24
25
|
/** Per-instance style overrides (same pattern as the other bubbles). */
|
|
25
26
|
style?: CometChatTheme["voiceNoteBubbleStyles"];
|
|
27
|
+
/** Render-time params from the message list — carries the consumer's `textFormatters`. */
|
|
28
|
+
additionalParams?: AdditionalParams;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
/**
|
|
@@ -33,6 +36,7 @@ export function CometChatVoiceNoteBubble({
|
|
|
33
36
|
message,
|
|
34
37
|
theme,
|
|
35
38
|
style,
|
|
39
|
+
additionalParams,
|
|
36
40
|
}: CometChatVoiceNoteBubbleProps) {
|
|
37
41
|
const compTheme = useCompTheme();
|
|
38
42
|
const s = deepMerge(theme.voiceNoteBubbleStyles ?? {}, compTheme.voiceNoteBubbleStyles ?? {}, style ?? {});
|
|
@@ -60,6 +64,7 @@ export function CometChatVoiceNoteBubble({
|
|
|
60
64
|
{Boolean(caption) && (
|
|
61
65
|
<CometChatCaptionText
|
|
62
66
|
message={message}
|
|
67
|
+
additionalParams={additionalParams}
|
|
63
68
|
caption={caption}
|
|
64
69
|
theme={theme}
|
|
65
70
|
containerStyle={{
|
|
@@ -37,6 +37,8 @@ type ErrorEmptyViewProps = {
|
|
|
37
37
|
* A custom JSX element to render for a retry action.
|
|
38
38
|
*/
|
|
39
39
|
RetryView?: JSX.Element;
|
|
40
|
+
/** Forwarded to the container so a caller can identify which state rendered. */
|
|
41
|
+
testID?: string;
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
|
|
@@ -50,9 +52,10 @@ export const ErrorEmptyView = (props: ErrorEmptyViewProps) => {
|
|
|
50
52
|
titleStyle = {},
|
|
51
53
|
subTitleStyle = {},
|
|
52
54
|
RetryView = null,
|
|
55
|
+
testID,
|
|
53
56
|
} = props;
|
|
54
57
|
return (
|
|
55
|
-
<View style={[containerStyle]}>
|
|
58
|
+
<View testID={testID} style={[containerStyle]}>
|
|
56
59
|
{Icon}
|
|
57
60
|
{title && <Text style={titleStyle}>{title}</Text>}
|
|
58
61
|
{subTitle && <Text style={subTitleStyle}>{subTitle}</Text>}
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
getConversationStyleDark,
|
|
7
7
|
getConversationStyleLight,
|
|
8
8
|
} from "../../CometChatConversations/style";
|
|
9
|
+
import { getPinnedMessagesStyleDark, getPinnedMessagesStyleLight } from "../../CometChatPinnedMessages/style";
|
|
10
|
+
import { getSavedMessagesStyleDark, getSavedMessagesStyleLight } from "../../CometChatSavedMessages/style";
|
|
9
11
|
import {
|
|
10
12
|
getNotificationFeedStyleDark,
|
|
11
13
|
getNotificationFeedStyleLight,
|
|
@@ -135,6 +137,8 @@ export const lightThemeMaker = (
|
|
|
135
137
|
dateSeparatorStyles: getDateSeparatorStyleLight(color, spacing, typography),
|
|
136
138
|
conversationStyles: getConversationStyleLight(color, spacing, typography),
|
|
137
139
|
notificationFeedStyles: getNotificationFeedStyleLight(color, spacing, typography),
|
|
140
|
+
pinnedMessagesStyles: getPinnedMessagesStyleLight(color, spacing, typography),
|
|
141
|
+
savedMessagesStyles: getSavedMessagesStyleLight(color, spacing, typography),
|
|
138
142
|
confirmDialogStyles: getConfirmDialogStyleLight(color, spacing, typography),
|
|
139
143
|
reportDialogStyles: getReportDialogStyleLight(color, spacing, typography),
|
|
140
144
|
messageHeaderStyles: getMessageHeaderStyle(color, spacing, typography),
|
|
@@ -177,6 +181,8 @@ export const darkThemeMaker = (
|
|
|
177
181
|
dateSeparatorStyles: getDateSeparatorStyleDark(color, spacing, typography),
|
|
178
182
|
conversationStyles: getConversationStyleDark(color, spacing, typography),
|
|
179
183
|
notificationFeedStyles: getNotificationFeedStyleDark(color, spacing, typography),
|
|
184
|
+
pinnedMessagesStyles: getPinnedMessagesStyleDark(color, spacing, typography),
|
|
185
|
+
savedMessagesStyles: getSavedMessagesStyleDark(color, spacing, typography),
|
|
180
186
|
confirmDialogStyles: getConfirmDialogStyleDark(color, spacing, typography),
|
|
181
187
|
reportDialogStyles: getReportDialogStyleDark(color, spacing, typography),
|
|
182
188
|
messageHeaderStyles: getMessageHeaderStyle(color, spacing, typography),
|
package/src/theme/type.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ColorValue, ImageSourcePropType, ImageStyle, TextStyle, ViewStyle } from "react-native";
|
|
2
2
|
import { CallButtonStyle } from "../calls/CometChatCallButtons";
|
|
3
3
|
import { ConversationStyle } from "../CometChatConversations/style";
|
|
4
|
+
import { PinnedMessagesStyle } from "../CometChatPinnedMessages/style";
|
|
5
|
+
import { SavedMessagesStyle } from "../CometChatSavedMessages/style";
|
|
4
6
|
import { GroupMemberStyle } from "../CometChatGroupMembers/style";
|
|
5
7
|
import { GroupStyle } from "../CometChatGroups/GroupsStyle";
|
|
6
8
|
import { MessageComposerStyle } from "../CometChatMessageComposer/styles";
|
|
@@ -543,6 +545,8 @@ export interface CometChatTheme {
|
|
|
543
545
|
callLogsStyles: CallLogsStyle;
|
|
544
546
|
conversationStyles: ConversationStyle;
|
|
545
547
|
notificationFeedStyles: NotificationFeedStyle;
|
|
548
|
+
pinnedMessagesStyles: PinnedMessagesStyle;
|
|
549
|
+
savedMessagesStyles: SavedMessagesStyle;
|
|
546
550
|
confirmDialogStyles: ConfirmDialogStyle;
|
|
547
551
|
reportDialogStyles: ReportDialogStyle;
|
|
548
552
|
quickReactionStyle: {
|