Skip to content

Commit

Permalink
v4.3.20
Browse files Browse the repository at this point in the history
  • Loading branch information
mathews-cometchat committed Sep 25, 2024
1 parent a0d76b2 commit 802f778
Show file tree
Hide file tree
Showing 41 changed files with 407 additions and 211 deletions.
6 changes: 6 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" android:host="*" />
</intent>
</queries>
<application android:requestLegacyExternalStorage="true"
android:largeHeap="true" >
<activity
Expand Down
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.19",
"version": "4.3.20",
"description": "Ready-to-use Chat UI Components for React Native",
"main": "src/index",
"module": "src/index",
Expand Down
44 changes: 19 additions & 25 deletions src/CometChatConversations/CometChatConversations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,11 @@ export const CometChatConversations = (props: ConversationInterface) => {
const userEventHandler = (...args: any[]) => {
const { uid, blockedByMe, status } = args[0];
if (!blockedByMe) {
let item: CometChat.Conversation | any = conversationListRef.current?.getListItem(`${uid}_user_${loggedInUser.current?.uid}`) || conversationListRef.current?.getListItem(`${loggedInUser.current?.uid}_user_${uid}`);
let item: CometChat.Conversation | any = conversationListRef.current?.getListItem(`${uid}_user_${loggedInUser.current?.uid}`) as unknown as CometChat.Conversation || conversationListRef.current?.getListItem(`${loggedInUser.current?.uid}_user_${uid}`) as unknown as CometChat.Conversation;
if (item) {
let updatedConversation = CommonUtils.clone(item);
updatedConversation.setConversationWith(args[0]);
conversationListRef.current.updateList(updatedConversation);
conversationListRef.current?.updateList(updatedConversation);
}
}
}
Expand Down Expand Up @@ -566,18 +566,18 @@ export const CometChatConversations = (props: ConversationInterface) => {
}

const updateMessageReceipt = (receipt: CometChat.MessageReceipt) => {
const conv: CometChat.Conversation =
const conv: CometChat.Conversation | boolean =
receipt?.getReceiverType() === ReceiverTypeConstants.user
? conversationListRef.current.getListItem(
? conversationListRef.current?.getListItem(
`${receipt?.getReceiver()}_user_${receipt?.getSender().getUid()}`
) ||
conversationListRef.current.getListItem(
) as unknown as CometChat.Conversation ||
conversationListRef.current?.getListItem(
`${receipt?.getSender()?.getUid()}_user_${receipt?.getReceiver()}`
)
) as unknown as CometChat.Conversation
: [receipt.RECEIPT_TYPE.DELIVERED_TO_ALL_RECEIPT, receipt.RECEIPT_TYPE.READ_BY_ALL_RECEIPT].includes(receipt?.getReceiptType()) &&
conversationListRef.current.getListItem(
conversationListRef.current?.getListItem(
`group_${receipt?.getReceiver()}`
);
) as unknown as CometChat.Conversation;

if (
conv &&
Expand All @@ -590,17 +590,17 @@ export const CometChatConversations = (props: ConversationInterface) => {
if (
conv &&
conv?.getLastMessage &&
(conv.getLastMessage().id == receipt['messageId'] ||
conv.getLastMessage().messageId == receipt['messageId'])
(conv.getLastMessage().id == receipt.getMessageId() ||
conv.getLastMessage().messageId == receipt.getMessageId())
) {
let newConversation = CommonUtils.clone(conv);
if (receipt['readAt']) {
newConversation.getLastMessage().setReadAt(receipt['readAt']);
if (receipt.getReadAt()) {
newConversation.getLastMessage().setReadAt(receipt.getReadAt());
}
if (receipt['deliveredAt']) {
newConversation.getLastMessage().setDeliveredAt(receipt['deliveredAt']);
if (receipt.getDeliveredAt()) {
newConversation.getLastMessage().setDeliveredAt(receipt.getDeliveredAt());
}
conversationListRef.current.updateList(newConversation);
conversationListRef.current?.updateList(newConversation);
}
};

Expand Down Expand Up @@ -749,7 +749,7 @@ export const CometChatConversations = (props: ConversationInterface) => {

function getFormattedText(message: CometChat.BaseMessage, subtitle: string) {
let messageTextTmp = subtitle;
let allFormatters = [...(textFormatters || [])] || [];
let allFormatters = [...(textFormatters ?? [])];

if (!disableMentions && message.getMentionedUsers().length) {
let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
Expand Down Expand Up @@ -1057,14 +1057,8 @@ export const CometChatConversations = (props: ConversationInterface) => {
{
ccConversationDeleted:
({ conversation }: { conversation: CometChat.Conversation | any }) => {
CometChat.deleteConversation(conversation.getConversationId(), conversation.getConversationType())
.then((res: any) => {
conversationListRef.current?.removeItemFromList(conversation);
removeItemFromSelectionList(conversation.getConversationId())
})
.catch((err: any) => {
console.log("Error", err);
});
conversationListRef.current?.removeItemFromList(conversation.getConversationId());
removeItemFromSelectionList(conversation.getConversationId())
}
}
);
Expand Down
4 changes: 2 additions & 2 deletions src/CometChatGroups/CometChatGroups.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useState, useRef } from "react";
//@ts-ignore
import { Text, TextStyle, View, ViewProps } from "react-native";
import {
backIcon, searchIcon,
backIcon,
passwordGroupIcon, privateGroupIcon,
checkIcon,
} from "./resources";
Expand Down Expand Up @@ -595,7 +595,7 @@ CometChatGroups.defaultProps = {
title: localize("GROUPS"),
searchPlaceHolderText: localize("SEARCH"),
showBackButton: false,
searchBoxIcon: searchIcon,
searchBoxIcon: undefined,
hideSearch: false,
listItemStyle: undefined,
avatarStyle: undefined,
Expand Down
29 changes: 13 additions & 16 deletions src/CometChatGroups/GroupsConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { GroupsStyle, GroupsStyleInterface } from './GroupsStyle';
import {
backIcon,
searchIcon,
passwordGroupIcon,
privateGroupIcon,
} from './resources';
Expand Down Expand Up @@ -60,23 +59,23 @@ export class GroupsConfiguration implements GroupsConfigurationInterface {
ListItemView!: (item: CometChat.Group) => JSX.Element;
AppBarOption!: () => JSX.Element;
options!: (item: CometChat.Group) => CometChatOptions[];
hideSeparator: boolean;
searchPlaceholderText: string;
backButton: ImageType;
showBackButton: boolean;
selectionMode: 'none' | 'single' | 'multiple';
hideSeparator?: boolean;
searchPlaceholderText?: string;
backButton?: ImageType;
showBackButton?: boolean;
selectionMode?: 'none' | 'single' | 'multiple';
onSelection!: (items: Array<CometChat.Group>) => void;
searchBoxIcon: ImageType;
hideSearch: boolean;
title: string;
searchBoxIcon?: ImageType;
hideSearch?: boolean;
title?: string;
EmptyStateView!: () => JSX.Element;
ErrorStateView!: () => JSX.Element;
LoadingStateView!: () => JSX.Element;
groupsRequestBuilder: CometChat.GroupsRequestBuilder | undefined;
searchKeyword: string;
privateGroupIcon: ImageType;
passwordGroupIcon: ImageType;
hideError: boolean;
searchKeyword?: string;
privateGroupIcon?: ImageType;
passwordGroupIcon?: ImageType;
hideError?: boolean;
onItemPress?: (item: CometChat.Group) => void;
onItemLongPress?: (item: CometChat.Group) => void;
onError?: (e: CometChat.CometChatException) => void;
Expand All @@ -89,8 +88,6 @@ export class GroupsConfiguration implements GroupsConfigurationInterface {

constructor(props: GroupsConfigurationInterface) {
if (props)
for (const [key, value] of Object.entries(props)) {
this[key] = value;
}
Object.assign(this, props);
}
}
3 changes: 0 additions & 3 deletions src/CometChatGroups/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import backIcon from "./back.png";
//@ts-ignore
import createIcon from "./create.png";
//@ts-ignore
import searchIcon from "./search.png";
//@ts-ignore
import passwordGroupIcon from "./password.png";
//@ts-ignore
import privateGroupIcon from "./private.png";
Expand All @@ -22,7 +20,6 @@ import checkIcon from './check.png';
export {
backIcon,
createIcon,
searchIcon,
passwordGroupIcon,
privateGroupIcon,
loadingIcon,
Expand Down
Binary file removed src/CometChatGroups/resources/search.png
Binary file not shown.
8 changes: 6 additions & 2 deletions src/CometChatMessageComposer/CometChatMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ let recordedTime = 0, timerIntervalId = null;
export interface MessageComposerStyleInterface extends BaseStyle {
attachIconTint?: string;
sendIconTint?: string;
voiceRecordingIconTint?: string;
inputBackground?: string;
inputBorder?: BorderStyleInterface;
dividerTint?: string;
Expand Down Expand Up @@ -1210,7 +1211,10 @@ export const CometChatMessageComposer = React.forwardRef(
const RecordAudioButtonView = () => {
return <ImageButton
image={voiceRecordingIconURL || ICONS.MICROPHONE}
imageStyle={Style.imageStyle}
imageStyle={[
Style.imageStyle,
messageComposerStyle?.voiceRecordingIconTint ? { tintColor: messageComposerStyle?.voiceRecordingIconTint } : {},
]}
onClick={() => setShowRecordAudio(true)}
/>
}
Expand All @@ -1228,7 +1232,7 @@ export const CometChatMessageComposer = React.forwardRef(
//fetch logged in user
useEffect(() => {
CometChat.getLoggedinUser().then((user: any) => (loggedInUser.current = user));
let _formatter = [...(textFormatters || [])] || [];
let _formatter = [...(textFormatters ?? [])];

if (!disableMentions) {
let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
Expand Down
43 changes: 31 additions & 12 deletions src/CometChatMessageInformation/MessageInformationConfiguration.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
import { CometChatMessageInformationInterface } from "./CometChatMessageInformation";
import { CometChatMessageInformationInterface } from './CometChatMessageInformation';

export interface MessageInformationConfigurationInterface extends
Omit<CometChatMessageInformationInterface,
'title' |
'message' |
'template' |
'bubbleView' |
'receiptDatePattern' |
'readIcon' |
'sentIcon' |
'deliveredIcon'
> {}
// Interface/Class merging: Class and Interface name should be the same. (below)
// Add a second interface for typing (if needed elsewhere)
// To avoid listing all properties individually in the class
export interface CometChatMessageInformationConfiguration
extends Omit<
CometChatMessageInformationInterface,
| 'title'
| 'message'
| 'template'
| 'BubbleView'
| 'receiptDatePattern'
| 'readIcon'
| 'sentIcon'
| 'deliveredIcon'
> {}

export interface CometChatMessageInformationConfigurationInterface
extends CometChatMessageInformationConfiguration {}

// Class name same as interface
export class CometChatMessageInformationConfiguration {
constructor(props: CometChatMessageInformationConfigurationInterface) {
if (props) {
for (const [key, value] of Object.entries(props)) {
//@ts-ignore - Ignore dynamic property assignment type checks
this[key] = value;
}
}
}
}
9 changes: 6 additions & 3 deletions src/CometChatMessageInformation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import {
CometChatMessageInformation,
CometChatMessageInformationInterface,
} from "./CometChatMessageInformation";
import { MessageInformationConfigurationInterface } from "./MessageInformationConfiguration";
import {
CometChatMessageInformationConfigurationInterface,
CometChatMessageInformationConfiguration
} from "./MessageInformationConfiguration";
import { MessageInformationStyleInterface } from "./MessageInformationStyle";

export { CometChatMessageInformation };
export { CometChatMessageInformation, CometChatMessageInformationConfiguration };
export type {
CometChatMessageInformationInterface,
MessageInformationConfigurationInterface,
CometChatMessageInformationConfigurationInterface,
MessageInformationStyleInterface,
};
33 changes: 24 additions & 9 deletions src/CometChatMessageList/CometChatMessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { CometChatUIEventHandler } from "../shared/events/CometChatUIEventHandle
import { ActionSheetStylesInterface } from "../shared/views/CometChatActionSheet/ActionSheetStyle";
import { CometChatMessageInformation } from "../CometChatMessageInformation/CometChatMessageInformation";
// import { CometChatContacts, ForwardMessageConfigurationInterface } from "../CometChatContacts";
import { MessageInformationConfigurationInterface } from "../CometChatMessageInformation";
import { CometChatMessageInformationConfigurationInterface } from "../CometChatMessageInformation";
import { InteractiveMessageUtils } from "../shared/utils/InteractiveMessageUtils";
import { CometChatEmojiKeyboard, EmojiKeyboardStyle } from "../shared/views/CometChatEmojiKeyboard";
import { CometChatReactionList, ReactionListConfigurationInterface } from "../shared/views/CometChatReactionList";
Expand Down Expand Up @@ -93,10 +93,15 @@ export interface CometChatMessageListProps {
onError?: (e: CometChat.CometChatException) => void,
onBack?: () => void,
// forwardMessageConfiguration?: ForwardMessageConfigurationInterface,
messageInformationConfiguration?: MessageInformationConfigurationInterface,
messageInformationConfiguration?: CometChatMessageInformationConfigurationInterface,
/**
* Hide the header of the action sheet
*/
/**
* @deprecated
*
* This property is deprecated as of version 4.3.20, as it is no longer needed. It will be removed in subsequent versions.
*/
hideActionSheetHeader?: boolean,
/**
* Message Reaction Configuration @ReactionsConfigurationInterface
Expand Down Expand Up @@ -181,7 +186,7 @@ export const CometChatMessageList = memo(forwardRef<
onBack,
// forwardMessageConfiguration
messageInformationConfiguration,
hideActionSheetHeader,
hideActionSheetHeader = true,
reactionsConfiguration,
disableReactions,
reactionListConfiguration,
Expand Down Expand Up @@ -672,7 +677,7 @@ export const CometChatMessageList = memo(forwardRef<
}
function checkSameConversation(message: CometChat.BaseMessage): boolean {
return message.getConversationId() == conversationId.current ||
(message.getSender()?.['uid'] === user?.getUid() && message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.user);
(message.getSender()?.getUid() === user?.getUid() && message.getReceiverType() == CometChatUiKitConstants.ReceiverTypeConstants.user);
}

function isNearBottom() {
Expand Down Expand Up @@ -865,7 +870,7 @@ export const CometChatMessageList = memo(forwardRef<
}

const handlePannel = (item: any) => {
if (item.alignment === ViewAlignment.messageListBottom && user && group && CommonUtils.checkIdBelongsToThisComponent(item.id, user, group, parentMessageId || '')) {
if (item.alignment === ViewAlignment.messageListBottom && (user || group) && CommonUtils.checkIdBelongsToThisComponent(item.id, user, group, parentMessageId || '')) {
if (item.child)
setCustomListHeader(() => item.child)
else
Expand Down Expand Up @@ -1321,9 +1326,11 @@ export const CometChatMessageList = memo(forwardRef<
if (timeStampAlignment == "top" || item['category'] == "action" || item['deletedAt']) return null

let isSender = (item.getSender()?.getUid() || item?.['sender']?.['uid']) == loggedInUser.current?.getUid();
let messageState;
const nextItemIsRead = messagesContentListRef.current[currentIndex + 1] && messagesContentListRef.current[currentIndex + 1].getReadAt();
const nextItemIsDelivered = messagesContentListRef.current[currentIndex + 1] && messagesContentListRef.current[currentIndex + 1].getDeliveredAt();
let messageState, nextItemIsRead, nextItemIsDelivered;
if(currentIndex !== undefined) {
nextItemIsRead = messagesContentListRef.current[currentIndex + 1] && messagesContentListRef.current[currentIndex + 1].getReadAt();
nextItemIsDelivered = messagesContentListRef.current[currentIndex + 1] && messagesContentListRef.current[currentIndex + 1].getDeliveredAt();
}
if (item.getReadAt() || nextItemIsRead)
messageState = "READ";
else if (item.getDeliveredAt() || nextItemIsDelivered)
Expand Down Expand Up @@ -1638,7 +1645,7 @@ export const CometChatMessageList = memo(forwardRef<
const openOptionsForMessage = useCallback((item: CometChat.BaseMessage | any, template: CometChatMessageTemplate) => {
let options = template?.options ? loggedInUser.current ? template.options(loggedInUser.current, item, group) : [] : [];
let optionsWithPressHandling = options.map(option => {
if (!option.onPress)
if (!option.onPress){
switch (option.id) {
case MessageOptionConstants.messageInformation:
option.onPress = openMessageInfo.bind(this, item);
Expand All @@ -1665,6 +1672,14 @@ export const CometChatMessageList = memo(forwardRef<
option.onPress = shareMedia.bind(this, item);
break;
}
}else{
// If overriding `onPress`, make sure to pass `item` explicitly
const customOnPress = option.onPress;
option.onPress = () =>{
customOnPress(item);
setShowMessageOptions([]);
}
}
if (option.id === MessageOptionConstants.reactToMessage) {
option.onPress = () => {
if (option.CustomView) {
Expand Down
Loading

0 comments on commit 802f778

Please sign in to comment.