From 55b03b5f7c3774572ba8a4510e38386c72ed2eb8 Mon Sep 17 00:00:00 2001 From: Rohit Ninawe <rohit.ninawe@cometchat.com> Date: Tue, 4 Jun 2024 15:40:25 +0530 Subject: [PATCH] v4.1.2 --- README.md | 2 +- package.json | 2 +- src/CometChatMessageList/CometChatMessageList.tsx | 12 ++++++------ src/shared/utils/conversationUtils.ts | 3 +++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 817d12d..a2448a0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![Platform](https://img.shields.io/badge/Platform-ReactNative-brightgreen.svg)](#) [![Platform](https://img.shields.io/badge/Language-TypeScript-yellowgreen.svg)](#) -![Version](https://shields.io/badge/version-v4.1.1-orange) +![Version](https://shields.io/badge/version-v4.1.2-orange) ![Twitter Follow](https://img.shields.io/twitter/follow/cometchat?style=social) ## Table of contents diff --git a/package.json b/package.json index 302cdfc..5af9d1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cometchat/chat-uikit-react-native", - "version": "4.1.1", + "version": "4.1.2", "description": "CometChat React Native UI Kit is a collection of custom UI Components designed to build text , chat and calling features in your application. The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly", "main": "src/index", "module": "src/index", diff --git a/src/CometChatMessageList/CometChatMessageList.tsx b/src/CometChatMessageList/CometChatMessageList.tsx index 40b7170..60ff97a 100644 --- a/src/CometChatMessageList/CometChatMessageList.tsx +++ b/src/CometChatMessageList/CometChatMessageList.tsx @@ -389,19 +389,19 @@ export const CometChatMessageList = forwardRef< .fetchNext() .then(newMessages => { let cleanUpdatedList = [...updatedList]; - for (let i = 0; i < cleanUpdatedList.length; i++) { + for (let i = (cleanUpdatedList.length - 1); i >= 0; i--) { if (cleanUpdatedList[i].id == lastID.current) break; - if (cleanUpdatedList[i].id == undefined) + if (cleanUpdatedList[i].id == undefined || Number.isNaN(parseInt(cleanUpdatedList[i].id))) cleanUpdatedList.splice(i, 1); } // console.log("newMessages", newMessages.length, JSON.stringify(newMessages)) - if (cleanUpdatedList?.length > 0 && cleanUpdatedList?.[0]?.["muid"]) { - let localFileExists = newMessages.findIndex(msg => msg?.["muid"] == cleanUpdatedList?.[0]?.["muid"]); + if (cleanUpdatedList?.length > 0 && cleanUpdatedList?.[cleanUpdatedList.length - 1]?.["muid"]) { + let localFileExists = newMessages.findIndex(msg => msg?.["muid"] == cleanUpdatedList?.[cleanUpdatedList.length - 1]?.["muid"]); if (localFileExists > -1) { cleanUpdatedList.shift(); } } - let tmpList = [...newMessages.reverse(), ...cleanUpdatedList]; + let tmpList = [...cleanUpdatedList, ...newMessages.reverse()]; tmpList = tmpList.map((item: CometChat.BaseMessage, index) => { if (item.getCategory() === MessageCategoryConstants.interactive) { return InteractiveMessageUtils.convertInteractiveMessage(item); @@ -570,7 +570,7 @@ export const CometChatMessageList = forwardRef< const deleteMessage = (message: CometChat.BaseMessage) => { CometChat.deleteMessage(message.getId().toString()) .then(res => { - messageEdited(res, false); + CometChatUIEventHandler.emitMessageEvent(MessageEvents.ccMessageDeleted, { message: res }); setShowMessageOptions([]); }) .catch(rej => { diff --git a/src/shared/utils/conversationUtils.ts b/src/shared/utils/conversationUtils.ts index 25d6dc6..8aba6e8 100644 --- a/src/shared/utils/conversationUtils.ts +++ b/src/shared/utils/conversationUtils.ts @@ -66,6 +66,9 @@ export class CometChatConversationUtils { } else if (lastMessage.getCategory() == CometChat.CATEGORY_CUSTOM as CometChat.MessageCategory) { msgText = lastMessage.getType(); } else if (lastMessage.getCategory() == CometChat.CATEGORY_ACTION as CometChat.MessageCategory) { + if ((lastMessage as CometChat.Action)?.getAction() === CometChat.ACTION_TYPE.MESSSAGE_DELETED) { + return localize("THIS_MESSAGE_DELETED"); + } msgText = (lastMessage as CometChat.Action).getMessage(); } else if (lastMessage.getCategory() === CometChat.CATEGORY_INTERACTIVE) { msgText = lastMessage.getType() === "form" ? `${localize('FORM')} 📋` : `${localize('CARD')} 🪧`;