Skip to content

Commit 9a60f01

Browse files
committed
v5.2.2
1 parent 8c783eb commit 9a60f01

File tree

26 files changed

+200
-55
lines changed

26 files changed

+200
-55
lines changed

packages/ChatUiKit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cometchat/chat-uikit-react-native",
3-
"version": "5.2.1",
3+
"version": "5.2.2",
44
"description": "Ready-to-use Chat UI Components for React Native",
55
"main": "src/index",
66
"module": "src/index",

packages/ChatUiKit/src/CometChatMessageComposer/CometChatMessageComposer.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,9 @@ export const CometChatMessageComposer = React.forwardRef(
14951495
if (shouldOpenList(selection, searchString, tracker)) {
14961496
activeCharacter.current = tracker;
14971497
searchStringRef.current = searchString;
1498+
// Show the suggestion list immediately (even while data is loading) to avoid layout jumps
14981499
setShowMentionList(true);
1500+
setSuggestionListLoader(true);
14991501

15001502
let formatter = allFormatters.current.get(tracker);
15011503
if (formatter instanceof CometChatMentionsFormatter) {
@@ -1514,6 +1516,7 @@ export const CometChatMessageComposer = React.forwardRef(
15141516
searchStringRef.current = "";
15151517
setShowMentionList(false);
15161518
setMentionsSearchData([]);
1519+
setSuggestionListLoader(false);
15171520
}
15181521
}, 100);
15191522
};
@@ -1701,7 +1704,6 @@ export const CometChatMessageComposer = React.forwardRef(
17011704
};
17021705

17031706
const textChangeHandler = (txt: string) => {
1704-
setPlainText(txt);
17051707
if (messagePreview) {
17061708
setHasEdited(txt.trim() !== originalText.trim());
17071709
}
@@ -1726,7 +1728,9 @@ export const CometChatMessageComposer = React.forwardRef(
17261728
let decr = 0;
17271729

17281730
plainTextInput.current = newText;
1729-
setPlainText(newText);
1731+
if (!(oldText.length > newText.length)) {
1732+
setPlainText(newText);
1733+
}
17301734

17311735
const newMentionMap: Map<string, SuggestionItem> = new Map(mentionMap.current);
17321736

@@ -1995,7 +1999,6 @@ export const CometChatMessageComposer = React.forwardRef(
19951999
{CustomView && CustomView}
19962000
</Modal>
19972001
<KeyboardAvoidingView
1998-
key={id}
19992002
behavior={Platform.OS === "ios" ? "padding" : "height"}
20002003
keyboardVerticalOffset={Platform.select({ ios: kbOffset })}
20012004
{...keyboardAvoidingViewProps}
@@ -2034,11 +2037,12 @@ export const CometChatMessageComposer = React.forwardRef(
20342037
mediaRecorderStyle={mergedComposerStyle.mediaRecorderStyle}
20352038
/>
20362039

2037-
{mentionsSearchData.length > 0 && (plainTextInput.current?.length ?? 0) > 0 && (
2040+
{showMentionList && (plainTextInput.current?.length ?? 0) > 0 && (
20382041
<View
20392042
style={[
20402043
theme.mentionsListStyle.containerStyle,
2041-
messagePreview ? { maxHeight: Dimensions.get("window").height * 0.2 } : {},
2044+
// Keep height stable to reduce flicker when list data loads/empties
2045+
{ maxHeight: Dimensions.get("window").height * (messagePreview ? 0.2 : (Platform.OS === "ios" ? 0.15 : 0.22)) },
20422046
]}
20432047
>
20442048
<CometChatSuggestionList

packages/ChatUiKit/src/CometChatMessageList/CometChatMessageList.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,35 @@ export const CometChatMessageList = memo(
13641364
conversationId.current = newMessage.getConversationId();
13651365
}
13661366

1367+
// ----------------------------------------------------------------------------------
1368+
// De-duplication / in-place update logic
1369+
// ----------------------------------------------------------------------------------
1370+
// Fix: Before inserting, check for an existing message with matching id OR muid.
1371+
// If found, update it in place instead of inserting again.
1372+
try {
1373+
const incomingId = (newMessage as any)?.getId?.();
1374+
const incomingMuid = (newMessage as any)?.muid || (newMessage as any)?.getMuid?.();
1375+
const existingIndex = messagesContentListRef.current.findIndex((m: any) => {
1376+
const mid = m?.getId?.();
1377+
const mmuid = m?.muid || m?.getMuid?.();
1378+
return (
1379+
(incomingId && mid && String(mid) === String(incomingId)) ||
1380+
(incomingMuid && mmuid && String(mmuid) === String(incomingMuid))
1381+
);
1382+
});
1383+
if (existingIndex !== -1) {
1384+
// Update existing message instead of duplicating.
1385+
const updatedList = [...messagesContentListRef.current];
1386+
updatedList[existingIndex] = CommonUtils.clone(newMessage);
1387+
messagesContentListRef.current = updatedList;
1388+
onLoad && onLoad([...messagesContentListRef.current].reverse());
1389+
setMessagesList(updatedList);
1390+
return; // prevent duplicate insert
1391+
}
1392+
} catch (e) {
1393+
console.log('Error in message de-duplication:', e);
1394+
}
1395+
13671396
const isStreamMessage = (newMessage as any).isStreamMessage;
13681397
const targetMessageId = (newMessage as any).targetMessageId;
13691398
if (isStreamMessage && targetMessageId) {
@@ -2587,6 +2616,9 @@ export const CometChatMessageList = memo(
25872616
if (hasTemplate?.BubbleView) return hasTemplate?.BubbleView(message);
25882617

25892618
const onLongPress = useCallback(() => {
2619+
// Ensure the keyboard is dismissed before showing options so the action sheet / menu isn't obscured
2620+
Keyboard.dismiss();
2621+
25902622
if (message.getDeletedBy() != null) return;
25912623

25922624
if (!message.getId()) {

packages/ChatUiKit/src/calls/CallingExtensionDecorator.tsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,12 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
227227
: theme.messageListStyles.incomingMessageBubbleStyles?.meetCallBubbleStyles;
228228

229229
const sentAt = message?.getSentAt() ? message.getSentAt() * 1000 : Date.now();
230+
const customData = message.getCustomData() as any;
230231
const callType = (message.getCustomData() as any).callType;
231232

233+
// Extract session ID with cross-platform compatibility
234+
const sessionId = customData.sessionId || customData.sessionID;
235+
232236
const BubbleIcon = (() => {
233237
if (isSentByMe) {
234238
if (callType === "audio") {
@@ -251,7 +255,7 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
251255
icon={BubbleIcon}
252256
onClick={() =>
253257
this.startDirectCall(
254-
(message.getCustomData() as any)["sessionId"],
258+
sessionId,
255259
message,
256260
theme,
257261
callType
@@ -281,9 +285,27 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
281285
theme?: CometChatTheme,
282286
callType?: string
283287
) {
284-
if (!(await permissionUtil.startResourceBasedTask(["mic", "camera"]))) {
288+
// Validate session ID
289+
if (!sessionId || sessionId === 'undefined' || sessionId === 'null') {
290+
console.error('[CallingExtensionDecorator] Invalid session ID provided:', sessionId);
291+
return;
292+
}
293+
294+
// Request only the necessary permissions based on call type.
295+
try {
296+
const resources: ("mic" | "camera")[] = callType === "audio" ? ["mic"] : ["mic", "camera"];
297+
const allowed = await permissionUtil.startResourceBasedTask(resources);
298+
if (!allowed) {
299+
console.warn(
300+
`[CallingExtensionDecorator] Permission check failed for resources: ${resources.join(",")}. Aborting join.`
301+
);
302+
return;
303+
}
304+
} catch (e) {
305+
console.error("[CallingExtensionDecorator] Unexpected error while requesting permissions", e);
285306
return;
286307
}
308+
287309
const callSettingsBuilder = (
288310
this.configuration?.groupCallSettingsBuilder
289311
? this.configuration?.groupCallSettingsBuilder(
@@ -300,6 +322,7 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
300322
});
301323
},
302324
onError: (error: CometChat.CometChatException) => {
325+
console.error("[CallingExtensionDecorator] OngoingCallListener onError while joining", error);
303326
CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccShowOngoingCall, {
304327
child: null,
305328
});
@@ -313,6 +336,7 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
313336
sessionID={sessionId}
314337
callSettingsBuilder={callSettingsBuilder}
315338
onError={(e) => {
339+
console.error("[CallingExtensionDecorator] CometChatOngoingCall onError for session", sessionId, e);
316340
CometChatUIEventHandler.emitCallEvent(CallUIEvents.ccShowOngoingCall, {
317341
child: null,
318342
});
@@ -375,8 +399,9 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
375399
}
376400
return <></>;
377401
},
378-
options: (loggedInUser, messageObject, group) => {
379-
return super.getCommonOptions(loggedInUser, messageObject, group);
402+
// Pass theme explicitly so common options (e.g. Message Privately) validate group context correctly.
403+
options: (loggedInUser, messageObject, _theme, group) => {
404+
return super.getCommonOptions(loggedInUser, messageObject, _theme, group);
380405
},
381406
});
382407
};

packages/ChatUiKit/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,28 @@ export const CometChatOngoingCall = (props: CometChatOngoingCallInterface): JSX.
4747
// Fetch the logged-in user and generate a token for the ongoing call session.
4848
CometChat.getLoggedinUser()
4949
.then((user) => {
50-
const authToken = user!.getAuthToken();
51-
CometChatCalls.generateToken(sessionID, authToken)
52-
.then((token: any) => {
53-
setToken(token.token);
54-
})
55-
.catch((rej: CometChat.CometChatException) => {
56-
setToken(undefined);
57-
onError && onError(rej);
58-
});
50+
if (!user) {
51+
throw new Error('No logged in user found');
52+
}
53+
54+
const authToken = user.getAuthToken();
55+
console.log('[CometChatOngoingCall] Got auth token, generating call token...');
56+
57+
return CometChatCalls.generateToken(sessionID, authToken);
5958
})
60-
.catch((rej) => {
61-
console.log("Error", rej);
62-
onError && onError(rej);
59+
.then((token: any) => {
60+
console.log('[CometChatOngoingCall] Successfully generated call token');
61+
setToken(token.token);
62+
})
63+
.catch((rej: CometChat.CometChatException | Error) => {
64+
console.error('[CometChatOngoingCall] Failed to generate token for session:', sessionID, rej);
65+
setToken(undefined);
66+
onError && onError(rej instanceof Error ?
67+
new CometChat.CometChatException({
68+
code: 'TOKEN_GENERATION_FAILED',
69+
message: rej.message
70+
}) : rej
71+
);
6372
});
6473

6574
// Cleanup call settings on unmount.

packages/ChatUiKit/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,5 +459,9 @@
459459
"START_A_CHAT": "Beginnen Sie einen Chat, indem Sie auf die Schaltfläche 'Neuer Chat' tippen",
460460
"CHAT_HISTORY": "Chat-Verlauf",
461461
"ASK_ANYTHING": "Frag etwas...",
462-
"AI_ASSISTANT": "AI-Assistent"
462+
"AI_ASSISTANT": "AI-Assistent",
463+
"START_REPORTING": "Bericht starten",
464+
"LOGOUT": "Abmelden",
465+
"AI_ASSISTANTS": "KI-Assistenten",
466+
"CREATE_CONVERSATION": "Konversation erstellen"
463467
}

packages/ChatUiKit/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,5 +458,9 @@
458458
"START_A_CHAT": "Click the 'New Chat' button to start a chat.",
459459
"CHAT_HISTORY": "Chat History",
460460
"ASK_ANYTHING": "Ask anything...",
461-
"AI_ASSISTANT": "AI Assistant"
461+
"AI_ASSISTANT": "AI Assistant",
462+
"START_REPORTING": "Start Reporting",
463+
"LOGOUT": "Logout",
464+
"AI_ASSISTANTS": "AI Assistants",
465+
"CREATE_CONVERSATION": "Create Conversation"
462466
}

packages/ChatUiKit/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,5 +459,9 @@
459459
"START_A_CHAT": "Comienza un chat tocando el botón 'Nueva conversación'",
460460
"CHAT_HISTORY": "Historial de chat",
461461
"ASK_ANYTHING": "Pregunta lo que sea...",
462-
"AI_ASSISTANT": "Asistente AI"
462+
"AI_ASSISTANT": "Asistente AI",
463+
"START_REPORTING": "Iniciar informe",
464+
"LOGOUT": "Cerrar sesión",
465+
"AI_ASSISTANTS": "Asistentes de IA",
466+
"CREATE_CONVERSATION": "Crear conversación"
463467
}

packages/ChatUiKit/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,5 +459,9 @@
459459
"START_A_CHAT": "Commencez un chat en appuyant sur le bouton 'Nouvelle conversation'",
460460
"CHAT_HISTORY": "Historique des chats",
461461
"ASK_ANYTHING": "Demandez n'importe quoi...",
462-
"AI_ASSISTANT": "Assistant IA"
462+
"AI_ASSISTANT": "Assistant IA",
463+
"START_REPORTING": "Commencer le rapport",
464+
"LOGOUT": "Se déconnecter",
465+
"AI_ASSISTANTS": "Assistants IA",
466+
"CREATE_CONVERSATION": "Créer une conversation"
463467
}

packages/ChatUiKit/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
"BANNED_MEMBERS": "प्रतिबंधित सदस्य",
176176
"NAME": "नाम",
177177
"SCOPE": "स्कोप",
178-
"UNBAN": "अनबन",
178+
"UNBAN": "प्रतिबंध हटाएँ",
179179
"SELECT_GROUP_TYPE": "ग्रुप क़िस्म चुनें",
180180
"ENTER_GROUP_PASSWORD": "ग्रुप पासवर्ड डालें",
181181
"CREATE": "बनाएँ",
@@ -291,7 +291,7 @@
291291
"DELETE_CONFIRM": "क्या आप वाकई डिलीट करना चाहते हैं?",
292292
"DELETE_CHAT": "इस चैट को डिलीट करें?",
293293
"SURE_TO_DELETE_CHAT": "क्या आप वाकई इस चैट को डिलीट करना चाहते हैं? इस क्रिया को पूर्ववत नहीं किया जा सकता।",
294-
"CANCEL": "कैंसिल करें",
294+
"CANCEL": "रद्द करें",
295295
"LEAVE_CONFIRM": "क्या आप वाकई समूह छोड़ना चाहते हैं?",
296296
"TRANSFER_CONFIRM": "आप समूह के स्वामी हैं; कृपया समूह छोड़ने से पहले किसी सदस्य को स्वामित्व हस्तांतरित करें",
297297
"ADDING": "जोड़ रहा है...",
@@ -434,7 +434,7 @@
434434
"GROUP_INFO": "ग्रुप जानकारी",
435435
"LEAVE_GROUP_TEXT": "इस ग्रुप को छोड़ें",
436436
"LEAVE_SURE": "क्या आप वाकई ग्रुप छोड़ना चाहते हैं? अब आप इस चैट से संदेश प्राप्त नहीं करेंगे।",
437-
"UNBAN_SURE": "क्या आप वाकई इस उपयोगकर्ता को अनबैन करना चाहते हैं?",
437+
"UNBAN_SURE": "क्या आप वाकई इस उपयोगकर्ता से प्रतिबंध हटाना चाहते हैं?",
438438
"DELETE_THIS_CONVERSATION": "क्या इस बातचीत को हटाना है?",
439439
"LINK": "लिंक",
440440
"DELETE_THIS_MESSAGE": "इस संदेश को हटाएं?",
@@ -458,5 +458,9 @@
458458
"START_A_CHAT": "'नई चैट' बटन पर टैप करके चैट शुरू करें।",
459459
"CHAT_HISTORY": "चैट इतिहास",
460460
"ASK_ANYTHING": "कुछ भी पूछें...",
461-
"AI_ASSISTANT": "एआई सहायक"
461+
"AI_ASSISTANT": "एआई सहायक",
462+
"START_REPORTING": "रिपोर्ट शुरू करें",
463+
"LOGOUT": "लॉगआउट करें",
464+
"AI_ASSISTANTS": "एआई सहायक",
465+
"CREATE_CONVERSATION": "बातचीत बनाएँ"
462466
}

0 commit comments

Comments
 (0)