Skip to content

Commit

Permalink
v4.3.18
Browse files Browse the repository at this point in the history
  • Loading branch information
mathews-cometchat committed Aug 21, 2024
1 parent 5613437 commit b43b2fa
Show file tree
Hide file tree
Showing 13 changed files with 249 additions and 103 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cometchat/chat-uikit-react-native",
"version": "4.3.17",
"version": "4.3.18",
"description": "Ready-to-use Chat UI Components for React Native",
"main": "src/index",
"module": "src/index",
Expand Down
3 changes: 2 additions & 1 deletion src/CometChatAddMembers/CometChatAddMembers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CometChatUsersInterface,
CometChatUsersActionsInterface,
} from '../CometChatUsers';
import { CometChatListStylesInterface, localize } from '../shared';
import { CometChatListStylesInterface, CometChatUiKitConstants, localize } from '../shared';
import { CometChatGroupsEvents } from '../shared/events';
import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler';
import { MessageTypeConstants } from '../shared/constants/UIKitConstants';
Expand Down Expand Up @@ -54,6 +54,7 @@ export const CometChatAddMembers = (props: CometChatAddMembersInterface) => {
CometChat.RECEIVER_TYPE.GROUP,
CometChat.CATEGORY_ACTION as CometChat.MessageCategory
);
action.setAction(CometChatUiKitConstants.groupMemberAction.ADDED);
action.setConversationId((group as any)['conversationId'])
action.setActionBy(loggedInUser.current);
action.setActionFor(group);
Expand Down
3 changes: 3 additions & 0 deletions src/CometChatBannedMembers/CometChatBannedMembers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
CometChatListProps,
CometChatListStylesInterface,
CometChatOptions,
CometChatUiKitConstants,
} from '../shared';
import { localize, ImageType } from '../shared';
import { CometChatGroupsEvents } from '../shared/events';
Expand Down Expand Up @@ -69,9 +70,11 @@ export const CometChatBannedMembers = (
CometChat.RECEIVER_TYPE.GROUP,
CometChat.CATEGORY_ACTION as CometChat.MessageCategory
);
action.setAction(CometChatUiKitConstants.groupMemberAction.UNBANNED)
action.setActionBy(loggedUserRef.current);
action.setMessage(`${loggedUserRef.current['name']} unbanned ${user['name']}}`)
action.setActionFor(group);
action.setActionOn(user)
action.setSender(loggedUserRef.current);

CometChatUIEventHandler.emitGroupEvent(
Expand Down
142 changes: 89 additions & 53 deletions src/CometChatConversations/CometChatConversations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ export interface ConversationInterface {
*/
disableUsersPresence?: boolean,
/**
* toggle react receipt view
*/
disableReadReceipt?: boolean,
/**
* disable message receipts
*/
* @deprecated
*
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
*/
disableReceipt?: boolean,
hideReceipt?: boolean,
/**
* toggle typing indicator
*/
Expand Down Expand Up @@ -250,8 +249,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
*/
const {
disableUsersPresence = false,
disableReadReceipt = false,
disableReceipt = false,
hideReceipt = false,
disableTyping = false,
disableSoundForMessages = false,
customSoundForMessages,
Expand Down Expand Up @@ -432,48 +431,74 @@ export const CometChatConversations = (props: ConversationInterface) => {
}


/**
* Check if last message/unread count should be updated
*
* @param newMessage message object
*/
const shouldUpdateLastMessageAndUnreadCount = (message: CometChat.BaseMessage) => {

/****Start: Should Threaded Messages Update Conversation? */
if (message.getParentMessageId() && !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnMessageReplies()) {
return false;
}
/****END: Should Threaded Messages Update Conversation? */

/****Start: Should Custom Message Update Conversation? */
if (message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.custom) {
let customMessage = message as CometChat.CustomMessage;
if (!customMessage.willUpdateConversation() &&
!(customMessage.getMetadata() && (customMessage.getMetadata() as any)["incrementUnreadCount"]) &&
!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCustomMessages()) {
return false;
}
}
/****End: Should Custom Message Update Conversation? */

/****Start: Should Group Actions sent update conversation? */
if (message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.action
&& message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.group
) {
return CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions();
}
/****End: Should Group Actions sent update conversation? */

/****Start: Should Call Actions sent Update Conversation? */
if (message.getCategory() == CometChatUiKitConstants.MessageCategoryConstants.call
&& !CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()
) {
return false;
}
/****End: Should Call Actions sent Update Conversation */

return true;
/**
* Check if last message/unread count should be updated
*
* @param newMessage message object
*/
const shouldUpdateLastMessageAndUnreadCount = (
message: CometChat.BaseMessage
) => {
const messageReceiverType = message.getReceiverType();
if (
conversationsRequestBuilder &&
conversationsRequestBuilder.build().getConversationType() &&
conversationsRequestBuilder.build().getConversationType() !=
messageReceiverType
) {
return false;
}
/****Start: Should Threaded Messages Update Conversation? */
if (
message.getParentMessageId() &&
!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnMessageReplies()
) {
return false;
}
/****END: Should Threaded Messages Update Conversation? */

/****Start: Should Custom Message Update Conversation? */
if (
message.getCategory() ==
CometChatUiKitConstants.MessageCategoryConstants.custom
) {
let customMessage = message as CometChat.CustomMessage;
if (
!customMessage.willUpdateConversation() &&
!(
customMessage.getMetadata() &&
(customMessage.getMetadata() as any)['incrementUnreadCount']
) &&
!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCustomMessages()
) {
return false;
}
}
/****End: Should Custom Message Update Conversation? */

/****Start: Should Group Actions sent update conversation? */
if (
message.getCategory() ==
CometChatUiKitConstants.MessageCategoryConstants.action &&
message.getReceiverType() ==
CometChatUiKitConstants.ReceiverTypeConstants.group
) {
return CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnGroupActions();
}
/****End: Should Group Actions sent update conversation? */

/****Start: Should Call Actions sent Update Conversation? */
if (
message.getCategory() ==
CometChatUiKitConstants.MessageCategoryConstants.call &&
!CometChatUIKit.getConversationUpdateSettings().shouldUpdateOnCallActivities()
) {
return false;
}
/****End: Should Call Actions sent Update Conversation */

return true;
};

/**
* Find conversation from state and udpate its last message object.
Expand Down Expand Up @@ -582,7 +607,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
*/
const messageEventHandler = (...args: any[]) => {
let message = args[0];
!disableReadReceipt && markMessageAsDelivered(message);
!disableReceipt && markMessageAsDelivered(message);
updateLastMessage(message);
}

Expand All @@ -591,6 +616,14 @@ export const CometChatConversations = (props: ConversationInterface) => {
* @param {obj} message
*/
const groupHandler = (message: any, otherDetails: {action?: string, actionOn?: CometChat.User, actionBy?: CometChat.User, group?: CometChat.Group} = {}) => {
if (
conversationsRequestBuilder &&
conversationsRequestBuilder.build().getConversationType() &&
conversationsRequestBuilder.build().getConversationType() !=
CometChatUiKitConstants.ReceiverTypeConstants.group
) {
return;
}
let conversation : CometChat.Conversation = (conversationListRef.current?.getListItem(message['conversationId']) as unknown as CometChat.Conversation);
let {action, actionOn, actionBy, group} = otherDetails;
if (conversation) {
Expand Down Expand Up @@ -763,15 +796,15 @@ export const CometChatConversations = (props: ConversationInterface) => {
</View>
}

if (lastMessage && !disableReadReceipt && lastMessage['sender']['uid'] == loggedInUser.current?.uid && !lastMessage.getDeletedAt()) {
if (lastMessage && lastMessage['sender']['uid'] == loggedInUser.current?.uid && !lastMessage.getDeletedAt()) {
let status: MessageReceipt = "ERROR";
if (lastMessage?.hasOwnProperty('readAt'))
status = "READ";
else if (lastMessage?.hasOwnProperty("deliveredAt"))
status = "DELIVERED";
else if (lastMessage?.hasOwnProperty("sentAt"))
status = "SENT";
readReceipt = disableReceipt ? null : <CometChatReceipt
readReceipt = (disableReceipt || hideReceipt) ? null : <CometChatReceipt
receipt={status}
deliveredIcon={props.deliveredIcon}
errorIcon={props.errorIcon}
Expand Down Expand Up @@ -1079,10 +1112,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
checkAndUpdateLastMessage(editedMessage)
},
onMessagesRead: (messageReceipt: any) => {
messageEventHandler(messageReceipt);
updateMessageReceipt(messageReceipt);
},
onMessagesDelivered: (messageReceipt: any) => {
messageEventHandler(messageReceipt);
updateMessageReceipt(messageReceipt);
},
onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
updateMessageReceipt(messageReceipt);
Expand Down Expand Up @@ -1184,6 +1217,9 @@ export const CometChatConversations = (props: ConversationInterface) => {
userListenerId,
{
ccUserBlocked: ({ user }: any) => {
if(conversationsRequestBuilder && conversationsRequestBuilder.build().isIncludeBlockedUsers()) {
return;
}
conversationListRef?.current?.removeItemFromList(user['conversationId']);
removeItemFromSelectionList(user['conversationId']);
}
Expand Down
14 changes: 14 additions & 0 deletions src/CometChatConversations/ConversationsConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import { BadgeStyleInterface } from "../shared/views/CometChatBadge";

export interface ConversationsConfigurationInterface {
disableUsersPresence?: boolean,
/**
* @deprecated
*
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
*/
disableReceipt?: boolean,
hideReceipt?: boolean,
disableTyping?: boolean,
disableSoundForMessages?: boolean,
customSoundForMessages?: string,
Expand Down Expand Up @@ -66,7 +72,13 @@ export interface ConversationsConfigurationInterface {
*/
export class ConversationsConfiguration implements ConversationsConfigurationInterface {
disableUsersPresence?: boolean;
/**
* @deprecated
*
* This property is deprecated as of version 4.3.18 due to newer property 'hideReceipt'. It will be removed in subsequent versions.
*/
disableReceipt?: boolean;
hideReceipt?: boolean;
disableTyping?: boolean;
disableSoundForMessages?: boolean;
customSoundForMessages?: string;
Expand Down Expand Up @@ -117,6 +129,7 @@ export class ConversationsConfiguration implements ConversationsConfigurationInt
constructor({
disableUsersPresence = false,
disableReceipt = false,
hideReceipt=false,
disableTyping = false,
disableSoundForMessages = false,
customSoundForMessages = undefined,
Expand Down Expand Up @@ -159,6 +172,7 @@ export class ConversationsConfiguration implements ConversationsConfigurationInt
}: ConversationsConfigurationInterface) {
this.disableUsersPresence = disableUsersPresence;
this.disableReceipt = disableReceipt;
this.hideReceipt=hideReceipt;
this.disableTyping = disableTyping;
this.disableSoundForMessages = disableSoundForMessages;
this.customSoundForMessages = customSoundForMessages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export const CometChatConversationsWithMessages = (props: CometChatConversations
undefined
}
{..._messagesConfig}
threadedMessagesConfiguration={_messagesConfig.threadedMessageConfiguration ? _messagesConfig.threadedMessageConfiguration : {}}
/>
</View>
}
Expand Down
10 changes: 10 additions & 0 deletions src/CometChatGroupMembers/CometChatGroupMembers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
groupRef.current && groupRef.current?.removeItemFromList(user.uid);
removeMemerFromSelectionList(user['uid']);
let action: CometChat.Action = new CometChat.Action(group['guid'], MessageTypeConstants.groupMember, CometChat.RECEIVER_TYPE.GROUP, CometChat.CATEGORY_ACTION as CometChat.MessageCategory);
action.setAction(CometChatUiKitConstants.groupMemberAction.BANNED)
action.setActionBy(loggedInUser.current);
action.setActionOn(user);
action.setActionFor(group);
Expand Down Expand Up @@ -276,6 +277,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
group.setMembersCount(group.getMembersCount() - 1);

let action: CometChat.Action = new CometChat.Action(group['guid'], MessageTypeConstants.groupMember, CometChat.RECEIVER_TYPE.GROUP, CometChat.CATEGORY_ACTION as CometChat.MessageCategory);
action.setAction(CometChatUiKitConstants.groupMemberAction.KICKED)
action.setActionBy(loggedInUser.current);
action.setActionOn(user);
action.setActionFor(group);
Expand Down Expand Up @@ -416,6 +418,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
groupRef.current?.updateList(updatedMember);
setShowChangeScope(false);
let action: CometChat.Action = new CometChat.Action(group['guid'], "groupMember", CometChat.RECEIVER_TYPE.GROUP, CometChat.CATEGORY_ACTION as CometChat.MessageCategory);
action.setAction(CometChatUiKitConstants.groupMemberAction.SCOPE_CHANGE)
action.setActionBy(loggedInUser.current);
action.setActionOn(member);
action.setActionFor(group);
Expand All @@ -424,6 +427,13 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
action.setMuid(String(getUnixTimestampInMilliseconds()));
action.setSender(loggedInUser.current);
action.setReceiver(group);
action.setData({
extras: {
scope: {
new: newScope,
},
},
})
CometChatUIEventHandler.emitGroupEvent(CometChatGroupsEvents.ccGroupMemberScopeChanged, { action, updatedUser: updatedMember, scopeChangedTo: newScope, scopeChangedFrom: member.scope, group });
})
.catch((err: any) => {
Expand Down
Loading

0 comments on commit b43b2fa

Please sign in to comment.