@cometchat/chat-uikit-react-native 5.3.6 → 5.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +18 -1
  2. package/ios/FileManager.m +14 -3
  3. package/ios/SoundPlayer.m +24 -1
  4. package/package.json +1 -1
  5. package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +8 -3
  6. package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +14 -11
  7. package/src/CometChatConversations/CometChatConversations.tsx +89 -51
  8. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +10 -11
  9. package/src/CometChatGroups/CometChatGroups.tsx +49 -42
  10. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +10 -7
  11. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +12 -10
  12. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -3
  13. package/src/CometChatMessageList/CometChatMessageList.tsx +398 -144
  14. package/src/CometChatMessageList/MANUAL_TEST_CASES.md +154 -0
  15. package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +4 -1
  16. package/src/CometChatSearch/CometChatSearch.tsx +8 -6
  17. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +4 -3
  18. package/src/CometChatUsers/CometChatUsers.tsx +56 -43
  19. package/src/calls/CallingExtensionDecorator.tsx +1 -1
  20. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -2
  21. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +7 -6
  22. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -1
  23. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -1
  24. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +4 -4
  25. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +5 -3
  26. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
  27. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -5
  28. package/src/extensions/Polls/PollsBubble.tsx +1 -1
  29. package/src/extensions/Polls/PollsDecorator.tsx +1 -1
  30. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -2
  31. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +9 -5
  32. package/src/shared/CometChatUiKit/CometChatUIKit.ts +87 -1
  33. package/src/shared/events/ListenerInitializer.ts +2 -1
  34. package/src/shared/framework/MessageDataSource.tsx +19 -15
  35. package/src/shared/helper/helperFunctions.ts +5 -4
  36. package/src/shared/services/stream-message.service.ts +0 -1
  37. package/src/shared/utils/CommonUtils.ts +1 -1
  38. package/src/shared/utils/MessageUtils.tsx +15 -13
  39. package/src/shared/utils/conversationUtils.ts +2 -2
  40. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +2 -2
  41. package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +17 -5
  42. package/src/shared/views/CometChatList/CometChatList.tsx +11 -15
  43. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +3 -3
  44. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +2 -1
  45. package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +15 -4
  46. package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -3
  47. package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +15 -1
  48. package/src/theme/provider.tsx +12 -12
@@ -164,14 +164,25 @@ const CometChatStreamMessageBubble: React.FC<CometChatStreamMessageBubbleProps>
164
164
  }, []);
165
165
 
166
166
  useEffect(() => {
167
+ let disconnectTimeout: ReturnType<typeof setTimeout> | null = null;
167
168
  const sub = streamConnection$.subscribe(({ status, error }) => {
168
169
  setConnectionStatus(status);
169
- if (status === 'disconnected' || status === 'error') {
170
- setHasError(true);
171
- stopStreamingForRunId();
170
+ if (status === 'connected') {
171
+ if (disconnectTimeout) {
172
+ clearTimeout(disconnectTimeout);
173
+ disconnectTimeout = null;
174
+ }
175
+ setHasError(false);
176
+ } else if (status === 'disconnected' || status === 'error') {
177
+ disconnectTimeout = setTimeout(() => {
178
+ setHasError(true);
179
+ }, 5000);
172
180
  }
173
181
  });
174
- return () => sub.unsubscribe();
182
+ return () => {
183
+ sub.unsubscribe();
184
+ if (disconnectTimeout) clearTimeout(disconnectTimeout);
185
+ };
175
186
  }, []);
176
187
 
177
188
  // Create markdown styles based on theme
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from "react";
1
+ import React, { useCallback, useEffect, useState } from "react";
2
2
  import { ActivityIndicator, FlatList, ListRenderItemInfo, View, Text } from "react-native";
3
3
  import { CometChatListItem } from "../CometChatListItem";
4
4
  import { SuggestionItem } from "./SuggestionItem";
@@ -52,7 +52,7 @@ export const CometChatSuggestionList = (props: CometChatSuggestionListInterface)
52
52
  }, 800);
53
53
  }, []);
54
54
 
55
- const _render = ({ item, index }: ListRenderItemInfo<SuggestionItem>) => {
55
+ const _render = useCallback(({ item, index }: ListRenderItemInfo<SuggestionItem>) => {
56
56
  let shouldLoadAvatarName = item.hideLeadingIcon ? {} : { avatarName: item.name };
57
57
  const isAllAlias = item.underlyingText?.startsWith?.('<@all:');
58
58
  const TitleView = isAllAlias ? (
@@ -82,7 +82,7 @@ export const CometChatSuggestionList = (props: CometChatSuggestionListInterface)
82
82
  {...shouldLoadAvatarName}
83
83
  />
84
84
  );
85
- };
85
+ }, [listStyle, theme, t, onPress]);
86
86
 
87
87
  return (
88
88
  <View>
@@ -1,4 +1,4 @@
1
- import React, { useLayoutEffect, useState, useRef, useCallback, useMemo, JSX } from "react";
1
+ import React, { useLayoutEffect, useEffect, useState, useRef, useCallback, useMemo, JSX } from "react";
2
2
  import {
3
3
  StyleProp,
4
4
  Text,
@@ -8,6 +8,7 @@ import {
8
8
  TouchableOpacity,
9
9
  LayoutChangeEvent,
10
10
  TextLayoutEvent,
11
+ Platform,
11
12
  } from "react-native";
12
13
  import {
13
14
  CometChatMentionsFormatter,
@@ -120,6 +121,19 @@ export const CometChatTextBubbleText = (
120
121
  }
121
122
  }, [text]);
122
123
 
124
+ // Android fallback: onTextLayout doesn't fire reliably for short texts.
125
+ // If measurement hasn't completed after 100ms, force it to resolve.
126
+ useEffect(() => {
127
+ if (Platform.OS === 'android' && !measurementComplete && containerWidth != null) {
128
+ const timeout = setTimeout(() => {
129
+ if (!measurementComplete) {
130
+ setMeasurementComplete(true);
131
+ }
132
+ }, 100);
133
+ return () => clearTimeout(timeout);
134
+ }
135
+ }, [text, containerWidth, measurementComplete]);
136
+
123
137
  // Handler to capture container width - use functional update to avoid dependency
124
138
  const onContainerLayout = useCallback((e: LayoutChangeEvent) => {
125
139
  const w = Math.round(e.nativeEvent.layout.width);
@@ -42,10 +42,9 @@ export const CometChatThemeProvider = ({
42
42
  theme = {} as any,
43
43
  }: PropsWithChildren<CometChatThemeProviderProps>) => {
44
44
  const rawScheme = useColorScheme();
45
- // For iOS, debounce the scheme value (300ms delay in this example).
46
- // For Android, use the raw value.
47
- const scheme =
48
- Platform.OS === "ios" ? useDebounce(rawScheme, 300) : rawScheme;
45
+ // Always call the hook unconditionally (Rules of Hooks), use result conditionally
46
+ const debouncedScheme = useDebounce(rawScheme, 300);
47
+ const scheme = Platform.OS === "ios" ? debouncedScheme : rawScheme;
49
48
 
50
49
  const parentProviderTheme = useThemeInternal();
51
50
  const {
@@ -113,15 +112,15 @@ export const CometChatThemeProvider = ({
113
112
  return parentProviderTheme.dark;
114
113
  }, [dark, parentProviderTheme.dark]);
115
114
 
116
- const themeValue = {
115
+ const resolvedMode = mode === "auto"
116
+ ? (typeof scheme === "string" ? scheme : "light")
117
+ : mode;
118
+
119
+ const themeValue = useMemo(() => ({
117
120
  light: lightTheme,
118
121
  dark: darkTheme,
119
- // Use the (conditionally) debounced scheme when determining the mode
120
- mode:
121
- mode === "auto"
122
- ? (typeof scheme === "string" ? scheme : "light")
123
- : mode,
124
- };
122
+ mode: resolvedMode,
123
+ }), [lightTheme, darkTheme, resolvedMode]);
125
124
 
126
125
  return (
127
126
  <ThemeContext.Provider value={themeValue}>
@@ -138,8 +137,9 @@ export const CometChatCompThemeProvider = ({
138
137
  children,
139
138
  theme = {} as any,
140
139
  }: PropsWithChildren<CometChatCompThemeProviderProps>) => {
140
+ const stableTheme = useMemo(() => theme, [theme]);
141
141
  return (
142
- <CompThemeContext.Provider value={theme}>
142
+ <CompThemeContext.Provider value={stableTheme}>
143
143
  {children}
144
144
  </CompThemeContext.Provider>
145
145
  );