From 802f77829d295ac5f5d00cf954b330f25e608ede Mon Sep 17 00:00:00 2001 From: Mathews Date: Wed, 25 Sep 2024 21:10:48 +0530 Subject: [PATCH] v4.3.20 --- android/src/main/AndroidManifest.xml | 6 + package.json | 2 +- .../CometChatConversations.tsx | 44 ++++---- src/CometChatGroups/CometChatGroups.tsx | 4 +- src/CometChatGroups/GroupsConfiguration.ts | 29 +++-- src/CometChatGroups/resources/index.ts | 3 - src/CometChatGroups/resources/search.png | Bin 435 -> 0 bytes .../CometChatMessageComposer.tsx | 8 +- .../MessageInformationConfiguration.tsx | 43 +++++-- src/CometChatMessageInformation/index.ts | 9 +- .../CometChatMessageList.tsx | 33 ++++-- .../MessageListConfiguration.ts | 21 ++++ src/CometChatTabs/CometChatTabs.tsx | 16 +-- .../CometChatThreadedMessages.tsx | 3 +- src/CometChatUsers/CometChatUsers.tsx | 51 +++++++-- src/CometChatUsers/UsersConfiguration.tsx | 4 +- src/CometChatUsers/UsersStyle.ts | 101 +++++++++++++++++ src/CometChatUsers/index.ts | 5 +- .../LinkPreview/LinkPreviewBubble.tsx | 2 +- .../MessageTranslationDecorator.tsx | 2 +- .../SmartReplies/SmartRepliesDecorator.tsx | 17 ++- src/index.ts | 10 +- .../CometChatUIEventHandler.ts | 106 +++++++++--------- src/shared/framework/MessageDataSource.tsx | 2 +- .../ImageZoom/ReactNativeZoomableView.tsx | 1 + .../ReactNativeZoomableViewWithGestures.tsx | 2 +- .../components/Control.tsx | 2 +- .../components/PlayPause/PlayPause.tsx | 2 +- src/shared/libs/luxon/src/impl/zoneUtil.js | 4 - src/shared/utils/CommonUtils.ts | 30 ++--- src/shared/utils/InteractiveMessageUtils.ts | 2 +- .../CometChatActionSheet/ActionSheetStyle.ts | 22 ++-- .../CometChatAudioBubble.tsx | 2 +- .../CometChatFileBubble.tsx | 4 +- .../CometChatFormBubble.tsx | 2 +- .../CometChatImageBubble.tsx | 6 +- .../CometChatImageBubble/assets/index.ts | 1 + .../MessageBubbleStyle.ts | 4 +- .../CometChatReactionList.tsx | 1 - .../CometChatSchedulerBubble.tsx | 10 +- .../CometChatVideoBubble.tsx | 2 +- 41 files changed, 407 insertions(+), 211 deletions(-) delete mode 100644 src/CometChatGroups/resources/search.png create mode 100644 src/CometChatUsers/UsersStyle.ts diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 0ce5e81..2513cab 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -4,6 +4,12 @@ + + + + + + { 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); } } } @@ -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 && @@ -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); } }; @@ -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(); @@ -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()) } } ); diff --git a/src/CometChatGroups/CometChatGroups.tsx b/src/CometChatGroups/CometChatGroups.tsx index 89e729f..73ada7d 100644 --- a/src/CometChatGroups/CometChatGroups.tsx +++ b/src/CometChatGroups/CometChatGroups.tsx @@ -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"; @@ -595,7 +595,7 @@ CometChatGroups.defaultProps = { title: localize("GROUPS"), searchPlaceHolderText: localize("SEARCH"), showBackButton: false, - searchBoxIcon: searchIcon, + searchBoxIcon: undefined, hideSearch: false, listItemStyle: undefined, avatarStyle: undefined, diff --git a/src/CometChatGroups/GroupsConfiguration.ts b/src/CometChatGroups/GroupsConfiguration.ts index 2a03148..8a2e98c 100644 --- a/src/CometChatGroups/GroupsConfiguration.ts +++ b/src/CometChatGroups/GroupsConfiguration.ts @@ -9,7 +9,6 @@ import { import { GroupsStyle, GroupsStyleInterface } from './GroupsStyle'; import { backIcon, - searchIcon, passwordGroupIcon, privateGroupIcon, } from './resources'; @@ -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) => 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; @@ -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); } } diff --git a/src/CometChatGroups/resources/index.ts b/src/CometChatGroups/resources/index.ts index 969a1a5..ca17a2e 100644 --- a/src/CometChatGroups/resources/index.ts +++ b/src/CometChatGroups/resources/index.ts @@ -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"; @@ -22,7 +20,6 @@ import checkIcon from './check.png'; export { backIcon, createIcon, - searchIcon, passwordGroupIcon, privateGroupIcon, loadingIcon, diff --git a/src/CometChatGroups/resources/search.png b/src/CometChatGroups/resources/search.png deleted file mode 100644 index bd8661a103c2185336acfc1ec8eee424ba50da60..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 435 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uuz(rC1}QWNE&K#jChO_q7-Atf zchW{bCP#rbetj2i`Nm^yx0(*!m=qCoAtA{<$vLyrKOsp$We@Y-xx9@{-+DH-1O(ie zFyqEdiKFk;cbD%zE+?h_v&i`K|IOCr0`3njmen%d{~)-nWq0W<;Tsk<6XOr9FKm9y zEmpuS6{OE7YteG(!dWS~gMsHt9ctOFo>(nk`gBSTUwh_pf3GRY5sq)X1DEhGyS(+= zz6`}v<*#OKi92dCZJof0wRwM|yZI`NpJgSS$c?=FD^|B^VO86v>tDOsPnC1jE$3$0 z8!x{l)Q-($N%^Oy==;)_d(x%PJ>V+Y-1e4r$FVdQ&MBb@ E0Mo3W-T(jq diff --git a/src/CometChatMessageComposer/CometChatMessageComposer.tsx b/src/CometChatMessageComposer/CometChatMessageComposer.tsx index 340a455..1b7eec8 100644 --- a/src/CometChatMessageComposer/CometChatMessageComposer.tsx +++ b/src/CometChatMessageComposer/CometChatMessageComposer.tsx @@ -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; @@ -1210,7 +1211,10 @@ export const CometChatMessageComposer = React.forwardRef( const RecordAudioButtonView = () => { return setShowRecordAudio(true)} /> } @@ -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(); diff --git a/src/CometChatMessageInformation/MessageInformationConfiguration.tsx b/src/CometChatMessageInformation/MessageInformationConfiguration.tsx index fffc1d4..2ceea97 100644 --- a/src/CometChatMessageInformation/MessageInformationConfiguration.tsx +++ b/src/CometChatMessageInformation/MessageInformationConfiguration.tsx @@ -1,13 +1,32 @@ -import { CometChatMessageInformationInterface } from "./CometChatMessageInformation"; +import { CometChatMessageInformationInterface } from './CometChatMessageInformation'; -export interface MessageInformationConfigurationInterface extends - Omit {} \ No newline at end of file +// 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; + } + } + } +} diff --git a/src/CometChatMessageInformation/index.ts b/src/CometChatMessageInformation/index.ts index f6f625f..0ce146c 100644 --- a/src/CometChatMessageInformation/index.ts +++ b/src/CometChatMessageInformation/index.ts @@ -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, }; diff --git a/src/CometChatMessageList/CometChatMessageList.tsx b/src/CometChatMessageList/CometChatMessageList.tsx index 7475819..3ace142 100644 --- a/src/CometChatMessageList/CometChatMessageList.tsx +++ b/src/CometChatMessageList/CometChatMessageList.tsx @@ -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"; @@ -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 @@ -181,7 +186,7 @@ export const CometChatMessageList = memo(forwardRef< onBack, // forwardMessageConfiguration messageInformationConfiguration, - hideActionSheetHeader, + hideActionSheetHeader = true, reactionsConfiguration, disableReactions, reactionListConfiguration, @@ -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() { @@ -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 @@ -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) @@ -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); @@ -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) { diff --git a/src/CometChatMessageList/MessageListConfiguration.ts b/src/CometChatMessageList/MessageListConfiguration.ts index fd35975..53ff03e 100644 --- a/src/CometChatMessageList/MessageListConfiguration.ts +++ b/src/CometChatMessageList/MessageListConfiguration.ts @@ -21,6 +21,7 @@ import { ReactionsConfigurationInterface } from '../shared/views/CometChatReacti import { ReactionListConfigurationInterface } from '../shared/views/CometChatReactionList'; import { QuickReactionsConfigurationInterface } from '../shared/views/CometChatQuickReactions'; import { EmojiKeyboardStyle } from '../shared/views/CometChatEmojiKeyboard'; +import { CometChatMessageInformationConfigurationInterface } from '../CometChatMessageInformation/MessageInformationConfiguration'; export interface MessageListConfigurationInterface { ErrorStateView?: (e: CometChat.CometChatException) => JSX.Element; @@ -91,6 +92,11 @@ export interface MessageListConfigurationInterface { /** * Hides 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 @@ -118,6 +124,11 @@ export interface MessageListConfigurationInterface { * @type {Array} */ textFormatters?: Array; + + /** + * Message Information Configuration @CometChatMessageInformationConfigurationInterface + */ + messageInformationConfiguration?: CometChatMessageInformationConfigurationInterface; } export class MessageListConfiguration implements MessageListConfigurationInterface { @@ -189,6 +200,11 @@ export class MessageListConfiguration /** * Hides 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 @@ -218,6 +234,11 @@ export class MessageListConfiguration */ textFormatters?: Array; + /** + * Message Information Configuration @CometChatMessageInformationConfigurationInterface + */ + messageInformationConfiguration?: CometChatMessageInformationConfigurationInterface; + constructor(props: MessageListConfigurationInterface) { if (props) { for (const [key, value] of Object.entries(props)) { diff --git a/src/CometChatTabs/CometChatTabs.tsx b/src/CometChatTabs/CometChatTabs.tsx index ed96f89..3100a64 100644 --- a/src/CometChatTabs/CometChatTabs.tsx +++ b/src/CometChatTabs/CometChatTabs.tsx @@ -27,7 +27,7 @@ export const CometChatTabs = (props: CometChatTabsInterface) => { keepAlive = false, tabAlignment = "bottom", } = props; - + const { theme } = React.useContext(CometChatContext); const [views, setViews] = useState>([]); @@ -45,7 +45,7 @@ export const CometChatTabs = (props: CometChatTabsInterface) => { },[props.tabs]); useEffect(() => { - loadActiveTab(); + loadActiveTab(); }, []) const getStyleFor = (tab: TabItem) => { @@ -67,8 +67,8 @@ export const CometChatTabs = (props: CometChatTabsInterface) => { titleTextColor: style?.tabTitleTextColor || theme?.palette.getAccent(), titleTextFont: style?.tabTitleTextFont || theme?.typography.body, activeIconTint: theme?.palette.getPrimary(), - activeTitleTextColor: style?.activeTabTitleTextColor || theme?.palette.getPrimary(), - activeBackgroundColor: style?.activeTabBackgroundColor || theme?.palette.getSecondary(), + activeTitleTextColor: style?.activeTabTitleTextColor || theme?.palette.getSecondary(), + activeBackgroundColor: style?.activeTabBackgroundColor || theme?.palette.getPrimary(), iconTint: theme?.palette.getAccent600(), activeTitleTextFont: theme?.typography.body, borderRadius: style?.borderRadius, @@ -80,7 +80,7 @@ export const CometChatTabs = (props: CometChatTabsInterface) => { width: tabs.length <= 4 ? (screenWidth - 30) / tabs.length : width, border: tab.isActive ? style?.activeTabBorder : undefined, borderRadius: style?.borderRadius, - backgroundColor: tab.isActive ? activeBackgroundColor : style?.backgroundColor, + backgroundColor: tab.isActive ? activeBackgroundColor : "transparent", tintColor: tab.isActive ? activeIconTint : iconTint, color: tab.isActive ? activeTitleTextColor : titleTextColor, titleFont: tab.isActive ? activeTitleTextFont : titleTextFont, @@ -126,9 +126,9 @@ export const CometChatTabs = (props: CometChatTabsInterface) => { setTabs(newTabState); } - const TabItemView = ({ item }) => { + const TabItemView = ({ item }: {item: any}) => { let style = getStyleFor(item); - + return ( { const TabsList = () => { return ( - + { tabs.map(item=> ) } ) diff --git a/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx b/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx index 1ad9ed4..9ee1c45 100644 --- a/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +++ b/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx @@ -257,7 +257,7 @@ export const CometChatThreadedMessages = ( titleStyle={({ ...theme.typography.heading, color: theme.palette.getAccent(), - ...threadedMessagesStyle.titleStyle + ...threadedMessagesStyle?.titleStyle }) as TextStyle } closeIconTint={ @@ -304,6 +304,7 @@ export const CometChatThreadedMessages = ( user={user} group={group} onError={onError && onError} + hideActionSheetHeader={true} {...(messageListConfiguration ? messageListConfiguration : {})} /> )} diff --git a/src/CometChatUsers/CometChatUsers.tsx b/src/CometChatUsers/CometChatUsers.tsx index e92feb9..fb74e9d 100644 --- a/src/CometChatUsers/CometChatUsers.tsx +++ b/src/CometChatUsers/CometChatUsers.tsx @@ -4,12 +4,16 @@ import React, { useRef, useEffect, useImperativeHandle } from 'react'; //@ts-ignore import { CometChat } from '@cometchat/chat-sdk-react-native'; import { + BorderStyle, + CometChatContext, + CometChatContextType, CometChatList, CometChatListActionsInterface, CometChatListProps, CometChatListStylesInterface, CometChatOptions, } from '../shared'; +import {UsersStyle, UsersStyleInterface} from './UsersStyle' import { CometChatUIEventHandler } from '../shared/events/CometChatUIEventHandler/CometChatUIEventHandler'; export interface CometChatUsersInterface @@ -61,10 +65,10 @@ export interface CometChatUsersInterface usersRequestBuilder?: CometChat.UsersRequestBuilder; /** * - * @type {CometChatListStylesInterface} + * @type {UsersStyleInterface} * pass custom styling for user */ - usersStyle?: CometChatListStylesInterface; + usersStyle?: UsersStyleInterface; /** * * Function which have user object as prop and takes a to render in place of subtitle view in list item @@ -103,18 +107,43 @@ export const CometChatUsers = React.forwardRef< const ccUserUnBlockedId = 'ccUserBlocked_' + new Date().getTime(); const { usersRequestBuilder, usersStyle, ...newProps } = props; + + //context values + const { theme } = React.useContext(CometChatContext); + const userRef = useRef(null); + + const _usersStyle = new UsersStyle({ + backgroundColor: theme?.palette.getBackgroundColor(), + backIconTint: theme?.palette.getPrimary(), + emptyTextColor: theme?.palette.getAccent400(), + emptyTextFont: theme?.typography.caption2, + errorTextColor: theme?.palette.getError(), + errorTextFont: theme?.typography.subtitle1, + searchBackgroundColor: theme?.palette.getAccent600(), + searchBorder: new BorderStyle({ + borderColor: theme?.palette.getAccent700(), + ...usersStyle?.border, + }), + separatorColor: theme?.palette.getAccent100(), + subtitleTextColor: theme?.palette.getAccent600(), + subtitleTextFont: theme?.typography.text1, + titleColor: theme?.palette.getAccent(), + titleFont: theme?.typography.title1, + loadingIconTint: theme?.palette.getPrimary(), + ...usersStyle +}); useImperativeHandle(ref, () => { return { - updateList: userRef.current.updateList, - addItemToList: userRef.current.addItemToList, - removeItemFromList: userRef.current.removeItemFromList, - getListItem: userRef.current.getListItem, - updateAndMoveToFirst: userRef.current.updateAndMoveToFirst, - getSelectedItems: userRef.current.getSelectedItems, - getAllListItems: userRef.current.getAllListItems, - clearSelection: userRef.current.clearSelection + updateList: userRef.current!.updateList, + addItemToList: userRef.current!.addItemToList, + removeItemFromList: userRef.current!.removeItemFromList, + getListItem: userRef.current!.getListItem, + updateAndMoveToFirst: userRef.current!.updateAndMoveToFirst, + getSelectedItems: userRef.current!.getSelectedItems, + getAllListItems: userRef.current!.getAllListItems, + clearSelection: userRef.current!.clearSelection }; }); @@ -166,7 +195,7 @@ export const CometChatUsers = React.forwardRef< ref={userRef} title={'Users'} requestBuilder={usersRequestBuilder} - listStyle={usersStyle} + listStyle={{ ..._usersStyle, background: _usersStyle.backgroundColor }} {...newProps as CometChatListProps} listItemKey="uid" /> diff --git a/src/CometChatUsers/UsersConfiguration.tsx b/src/CometChatUsers/UsersConfiguration.tsx index f65bbb7..be8e71a 100644 --- a/src/CometChatUsers/UsersConfiguration.tsx +++ b/src/CometChatUsers/UsersConfiguration.tsx @@ -1,7 +1,6 @@ import { ListRenderItem, StyleProp, ViewStyle } from 'react-native'; import { AvatarStyleInterface, - CometChatListStylesInterface, CometChatOptions, ImageType, ListItemStyleInterface, @@ -10,6 +9,7 @@ import { StatusIndicatorStyleInterface } from '../shared/views/CometChatStatusIn import { CometChatUsersInterface } from './CometChatUsers'; //@ts-ignore import { CometChat } from '@cometchat/chat-sdk-react-native'; +import { UsersStyleInterface } from './UsersStyle' export interface UsersConfigurationInterface extends Omit< @@ -48,7 +48,7 @@ export class UsersConfiguration { TailView?: (item: CometChat.User) => JSX.Element; tailViewContainerStyle?: StyleProp; usersRequestBuilder?: CometChat.UsersRequestBuilder; - usersStyle?: CometChatListStylesInterface; + usersStyle?: UsersStyleInterface; constructor(props: UsersConfigurationInterface) { if (props) for (const [key, value] of Object.entries(props)) { diff --git a/src/CometChatUsers/UsersStyle.ts b/src/CometChatUsers/UsersStyle.ts new file mode 100644 index 0000000..8a386ef --- /dev/null +++ b/src/CometChatUsers/UsersStyle.ts @@ -0,0 +1,101 @@ +import { BaseStyle, BaseStyleInterface, BorderStyle, BorderStyleInterface, FontStyle, FontStyleInterface, ImageType } from "../shared"; +import { localize } from "../shared"; + +export interface UsersStyleInterface extends BaseStyleInterface { + titleFont?: FontStyleInterface; + titleColor?: string; + backIconTint?: string; + searchBorder?: BorderStyleInterface; + searchBorderRadius?: number; + searchBackgroundColor?: string; + searchTextFont?: FontStyleInterface; + searchTextColor?: string; + searchIconTint?: string; + searchPlaceHolderTextColor?: string + separatorColor?: string; + loadingIconTint?: string; + emptyTextColor?: string; + emptyTextFont?: FontStyleInterface; + errorTextColor?: string; + errorTextFont?: FontStyleInterface; + subtitleTextColor?: string; + subtitleTextFont?: FontStyleInterface; +} + +/** + * @class UsersStyle + * @description UsersStyle class is used for defining the UsersStyle template. + */ +export class UsersStyle extends BaseStyle { + titleFont: FontStyleInterface; + titleColor: string; + backIconTint: string; + searchBorder: BorderStyleInterface; + searchBorderRadius: number; + searchBackgroundColor: string; + searchTextFont: FontStyleInterface; + searchTextColor: string; + searchIconTint: string; + searchPlaceHolderTextColor: string; + separatorColor: string; + loadingIconTint: string; + emptyTextColor: string; + emptyTextFont: FontStyleInterface; + errorTextColor: string; + errorTextFont: FontStyleInterface; + subtitleTextColor: string; + subtitleTextFont: FontStyleInterface; + + constructor(props: UsersStyleInterface) { + const { + width = "100%", + height = "100%", + border = new BorderStyle({ borderWidth: 0 }), + borderRadius = 0, + backgroundColor = "white", + titleFont = new FontStyle({ fontSize: 17 }), + titleColor = '#141414', + backIconTint = "black", + searchBorder = new BorderStyle({}), + searchBorderRadius = 50, + searchBackgroundColor = "rgba(20, 20, 20, 0.04)", + searchTextFont = new FontStyle({ fontSize: 17 }), + searchTextColor = "rgba(20,20,20,0.58)", + searchIconTint = "rgba(20,20,20,0.4)", + searchPlaceHolderTextColor = "rgba(20,20,20,0.58)", + separatorColor = "rgba(20, 20, 20, 0.1)", + loadingIconTint = "rgba(20,20,20, 0.7)", + emptyTextColor = "rgb(255, 59, 48)", + emptyTextFont = new FontStyle({ fontSize: 20 }), + errorTextColor = "rgb(255, 59, 48)", + errorTextFont = new FontStyle({ fontSize: 20 }), + subtitleTextColor = "rgba(20, 20, 20, 0.58)", + subtitleTextFont = new FontStyle({ fontSize: 16 }), + } = props; + super({ + width, + height, + backgroundColor, + border, + borderRadius + }); + this.titleFont = titleFont; + this.titleColor = titleColor; + this.backIconTint = backIconTint; + this.searchBorder = searchBorder; + this.searchBorderRadius = searchBorderRadius; + this.searchBackgroundColor = searchBackgroundColor; + this.searchTextFont = searchTextFont; + this.searchTextColor = searchTextColor; + this.searchIconTint = searchIconTint; + this.searchPlaceHolderTextColor = searchPlaceHolderTextColor; + this.separatorColor = separatorColor; + this.loadingIconTint = loadingIconTint; + this.emptyTextColor = emptyTextColor; + this.emptyTextFont = emptyTextFont; + this.errorTextColor = errorTextColor; + this.errorTextFont = errorTextFont; + this.subtitleTextColor = subtitleTextColor; + this.subtitleTextFont = subtitleTextFont; + } +} \ No newline at end of file diff --git a/src/CometChatUsers/index.ts b/src/CometChatUsers/index.ts index 1d234a6..4c82035 100644 --- a/src/CometChatUsers/index.ts +++ b/src/CometChatUsers/index.ts @@ -4,13 +4,16 @@ import { CometChatUsersActionsInterface, } from "./CometChatUsers"; +import { UsersStyle, UsersStyleInterface } from "./UsersStyle" + import { UsersConfiguration, UsersConfigurationInterface, } from "./UsersConfiguration"; -export { CometChatUsers, UsersConfiguration }; +export { CometChatUsers, UsersStyle, UsersConfiguration }; export type { CometChatUsersInterface, CometChatUsersActionsInterface, UsersConfigurationInterface, + UsersStyleInterface }; diff --git a/src/extensions/LinkPreview/LinkPreviewBubble.tsx b/src/extensions/LinkPreview/LinkPreviewBubble.tsx index 9a73fd7..2264f35 100644 --- a/src/extensions/LinkPreview/LinkPreviewBubble.tsx +++ b/src/extensions/LinkPreview/LinkPreviewBubble.tsx @@ -31,7 +31,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => { const [imageSource, setImageSource] = useState({ uri: image.startsWith("https:") ? image : `https:${image.split("http:")[1]}` }); const callCount = useRef(0); - const timerId = useRef(null); + const timerId = useRef(null); const threshold = 10; const timeframe = 1000; diff --git a/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx b/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx index 2b79c52..a7cefde 100644 --- a/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +++ b/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx @@ -199,7 +199,7 @@ export class MessageTranslationExtensionDecorator extends DataSourceDecorator { let loggedInUser = CometChatUIKit.loggedInUser; let mentionedUsers = message.getMentionedUsers(); - let textFormatters = [...(additionalParams?.textFormatters || [])] || []; + let textFormatters = [...(additionalParams?.textFormatters ?? [])]; let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser as any); linksTextFormatter.setMessage(message); diff --git a/src/extensions/SmartReplies/SmartRepliesDecorator.tsx b/src/extensions/SmartReplies/SmartRepliesDecorator.tsx index 860d972..e29c140 100644 --- a/src/extensions/SmartReplies/SmartRepliesDecorator.tsx +++ b/src/extensions/SmartReplies/SmartRepliesDecorator.tsx @@ -45,7 +45,12 @@ export class SmartRepliesDecorator extends DataSourceDecorator { ccActiveChatChanged: ({message}: any) => { if(message && message['sender']?.['uid'] != this.loggedInUser?.getUid()) this.getReplies(message); - }, + } + } + ); + CometChat.addMessageListener( + Date.now()+"", + { onTextMessageReceived: (textMessage: any) => { if(textMessage && textMessage['sender']?.['uid'] != this.loggedInUser?.getUid()) this.getReplies(textMessage); @@ -62,7 +67,7 @@ export class SmartRepliesDecorator extends DataSourceDecorator { return 'SmartReply'; } - getReplies(message: any) { + getReplies(message: CometChat.BaseMessage) { let id = CommonUtils.getComponentIdFromMessage(message); const smartReplyData = getExtentionData( @@ -95,7 +100,7 @@ export class SmartRepliesDecorator extends DataSourceDecorator { }); } - handleSendMessage = (message: any, smartReply: any) => { + handleSendMessage = (message: CometChat.BaseMessage, smartReply: any) => { let chatWithId = ''; let id = CommonUtils.getComponentIdFromMessage(message) let chatWith; @@ -103,11 +108,11 @@ export class SmartRepliesDecorator extends DataSourceDecorator { return; } if (typeof message !== 'object') return; - if (message?.receiverType === ReceiverTypeConstants.user) { - chatWithId = message?.sender?.uid; + if (message?.getReceiverType() === ReceiverTypeConstants.user) { + chatWithId = message?.getSender()?.getUid(); chatWith = ReceiverTypeConstants.user; } else { - chatWithId = message?.receiverId; + chatWithId = message?.getReceiverId(); chatWith = ReceiverTypeConstants.group; } let textMessage = new CometChat.TextMessage( diff --git a/src/index.ts b/src/index.ts index 780c301..fdd82f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -183,6 +183,8 @@ import { CometChatUsers, CometChatUsersActionsInterface, CometChatUsersInterface, + UsersStyle, + UsersStyleInterface, UsersConfigurationInterface, } from "./CometChatUsers"; @@ -266,7 +268,8 @@ import { import { CometChatMessageInformation, CometChatMessageInformationInterface, - MessageInformationConfigurationInterface, + CometChatMessageInformationConfigurationInterface, + CometChatMessageInformationConfiguration, MessageInformationStyleInterface, } from "./CometChatMessageInformation"; @@ -465,6 +468,7 @@ export { CometChatMessageComposer, CometChatDetails, CometChatUsers, + UsersStyle, CometChatAddMembers, CometChatBannedMembers, // @@ -577,6 +581,7 @@ export { /* Text Formatters */ DateTimeElement, CometChatDateTimePicker, + CometChatMessageInformationConfiguration }; export type { ThumbnailGenerationConfigurationInterface, @@ -635,6 +640,7 @@ export type { CometChatUsersActionsInterface, CometChatUsersInterface, UsersConfigurationInterface, + UsersStyleInterface, BannedMembersConfigurationInterface, CometChatBannedMembersInterface, AddMembersConfigurationInterface, @@ -714,7 +720,6 @@ export type { ContactsStyleInterface, StartConversationConfigurationInterface, CometChatMessageInformationInterface, - MessageInformationConfigurationInterface, MessageInformationStyleInterface, CometChatFormBubbleInterface, CometChatCardBubbleInterface, @@ -748,6 +753,7 @@ export type { SuggestionListConfigurationInterface, CometChatDateTimePickerInterface, DatePickerStyleInterface, + CometChatMessageInformationConfigurationInterface, }; // AI diff --git a/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts b/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts index 496bf3d..b11828d 100644 --- a/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts +++ b/src/shared/events/CometChatUIEventHandler/CometChatUIEventHandler.ts @@ -108,85 +108,85 @@ export class CometChatUIEventHandler { } static emitMessageEvent(name: string, param: object) { - CometChatUIEventHandler.messageHandlers.map((listener) => { + CometChatUIEventHandler.messageHandlers?.map((listener) => { switch (name) { - case listener._eventListener.ccMessageLiveReaction?.name: - listener._eventListener.ccMessageLiveReaction(param); + case listener._eventListener?.ccMessageLiveReaction?.name: + listener._eventListener?.ccMessageLiveReaction?.(param); break; - case listener._eventListener.ccMessageDeleted?.name: - listener._eventListener.ccMessageDeleted(param); + case listener._eventListener?.ccMessageDeleted?.name: + listener._eventListener?.ccMessageDeleted?.(param); break; - case listener._eventListener.ccMessageEdited?.name: - listener._eventListener.ccMessageEdited(param); + case listener._eventListener?.ccMessageEdited?.name: + listener._eventListener?.ccMessageEdited?.(param); break; - case listener._eventListener.ccMessageRead?.name: - listener._eventListener.ccMessageRead(param); + case listener._eventListener?.ccMessageRead?.name: + listener._eventListener?.ccMessageRead?.(param); break; - case listener._eventListener.ccMessageSent?.name: - listener._eventListener.ccMessageSent(param); + case listener._eventListener?.ccMessageSent?.name: + listener._eventListener?.ccMessageSent?.(param); break; - case listener._eventListener.ccMessageDelivered?.name: - listener._eventListener.ccMessageSent(param); + case listener._eventListener?.ccMessageDelivered?.name: + listener._eventListener?.ccMessageSent?.(param); break; - case listener._eventListener.ccActiveChatChanged?.name: - listener._eventListener.ccActiveChatChanged(param); + case listener._eventListener?.ccActiveChatChanged?.name: + listener._eventListener?.ccActiveChatChanged?.(param); break; - case listener._eventListener.onTextMessageReceived?.name: - listener._eventListener.onTextMessageReceived(param); + case listener._eventListener?.onTextMessageReceived?.name: + listener._eventListener?.onTextMessageReceived?.(param); break; - case listener._eventListener.onMediaMessageReceived?.name: - listener._eventListener.onMediaMessageReceived(param); + case listener._eventListener?.onMediaMessageReceived?.name: + listener._eventListener?.onMediaMessageReceived?.(param); break; - case listener._eventListener.onCustomMessageReceived?.name: - listener._eventListener.onCustomMessageReceived(param); + case listener._eventListener?.onCustomMessageReceived?.name: + listener._eventListener?.onCustomMessageReceived?.(param); break; - case listener._eventListener.onTypingStarted?.name: - listener._eventListener.onTypingStarted(param); + case listener._eventListener?.onTypingStarted?.name: + listener._eventListener?.onTypingStarted?.(param); break; - case listener._eventListener.onTypingEnded?.name: - listener._eventListener.onTypingEnded(param); + case listener._eventListener?.onTypingEnded?.name: + listener._eventListener?.onTypingEnded?.(param); break; - case listener._eventListener.onMessagesDelivered?.name: - listener._eventListener.onMessagesDelivered(param); + case listener._eventListener?.onMessagesDelivered?.name: + listener._eventListener?.onMessagesDelivered?.(param); break; - case listener._eventListener.onMessagesRead?.name: - listener._eventListener.onMessagesRead(param); + case listener._eventListener?.onMessagesRead?.name: + listener._eventListener?.onMessagesRead?.(param); break; - case listener._eventListener.onMessageEdited?.name: - listener._eventListener.onMessageEdited(param); + case listener._eventListener?.onMessageEdited?.name: + listener._eventListener?.onMessageEdited?.(param); break; - case listener._eventListener.onMessageDeleted?.name: - listener._eventListener.onMessageDeleted(param); + case listener._eventListener?.onMessageDeleted?.name: + listener._eventListener?.onMessageDeleted?.(param); break; - case listener._eventListener.onTransientMessageReceived?.name: - listener._eventListener.onTransientMessageReceived(param); + case listener._eventListener?.onTransientMessageReceived?.name: + listener._eventListener?.onTransientMessageReceived?.(param); break; - case listener._eventListener.onFormMessageReceived?.name: - listener._eventListener.onFormMessageReceived(param); + case listener._eventListener?.onFormMessageReceived?.name: + listener._eventListener?.onFormMessageReceived?.(param); break; - case listener._eventListener.onCardMessageReceived?.name: - listener._eventListener.onCardMessageReceived(param); + case listener._eventListener?.onCardMessageReceived?.name: + listener._eventListener?.onCardMessageReceived?.(param); break; - case listener._eventListener.onSchedulerMessageReceived?.name: - listener._eventListener.onSchedulerMessageReceived(param); + case listener._eventListener?.onSchedulerMessageReceived?.name: + listener._eventListener?.onSchedulerMessageReceived?.(param); break; - case listener._eventListener.onCustomInteractiveMessageReceived?.name: - listener._eventListener.onCustomInteractiveMessageReceived(param); + case listener._eventListener?.onCustomInteractiveMessageReceived?.name: + listener._eventListener?.onCustomInteractiveMessageReceived?.(param); break; - case listener._eventListener.onInteractionGoalCompleted?.name: - listener._eventListener.onInteractionGoalCompleted(param); + case listener._eventListener?.onInteractionGoalCompleted?.name: + listener._eventListener?.onInteractionGoalCompleted?.(param); break; - case listener._eventListener.onMessageReactionRemoved?.name: - listener._eventListener.onMessageReactionRemoved(param); + case listener._eventListener?.onMessageReactionRemoved?.name: + listener._eventListener?.onMessageReactionRemoved?.(param); break; - case listener._eventListener.onMessageReactionAdded?.name: - listener._eventListener.onMessageReactionAdded(param); + case listener._eventListener?.onMessageReactionAdded?.name: + listener._eventListener?.onMessageReactionAdded?.(param); break; - case listener._eventListener.onMessagesDeliveredToAll?.name: - listener._eventListener.onMessagesDeliveredToAll(param); + case listener._eventListener?.onMessagesDeliveredToAll?.name: + listener._eventListener?.onMessagesDeliveredToAll?.(param); break; - case listener._eventListener.onMessagesReadByAll?.name: - listener._eventListener.onMessagesReadByAll(param); + case listener._eventListener?.onMessagesReadByAll?.name: + listener._eventListener?.onMessagesReadByAll?.(param); break; } }); diff --git a/src/shared/framework/MessageDataSource.tsx b/src/shared/framework/MessageDataSource.tsx index 1b9140f..fb450fc 100644 --- a/src/shared/framework/MessageDataSource.tsx +++ b/src/shared/framework/MessageDataSource.tsx @@ -393,7 +393,7 @@ export class MessageDataSource implements DataSource { let loggedInUser = CometChatUIKit.loggedInUser; if(loggedInUser) { let mentionedUsers = message.getMentionedUsers(); - let textFormatters = [...(additionalParams?.textFormatters || [])] || []; + let textFormatters = [...(additionalParams?.textFormatters ?? [])]; let linksTextFormatter = ChatConfigurator.getDataSource().getUrlsFormatter(loggedInUser); linksTextFormatter.setMessage(message); diff --git a/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx b/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx index b46edca..0366ea7 100644 --- a/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +++ b/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx @@ -556,6 +556,7 @@ class ReactNativeZoomableView extends Component< this._handleShifting(gestureState); } } + return false; }; /** diff --git a/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx b/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx index ca048b1..7fa8052 100644 --- a/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +++ b/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx @@ -134,7 +134,7 @@ class ReactNativeZoomableViewWithGestures extends React.Component< const { dx, dy } = gestureState; if (!swipeLengthThreshold) { - return; + return null; } if (this._isValidHorizontalSwipe(gestureState)) { diff --git a/src/shared/libs/VideoPlayerControls/components/Control.tsx b/src/shared/libs/VideoPlayerControls/components/Control.tsx index 4b40ebe..75ef40b 100644 --- a/src/shared/libs/VideoPlayerControls/components/Control.tsx +++ b/src/shared/libs/VideoPlayerControls/components/Control.tsx @@ -5,7 +5,7 @@ import {styles} from './styles'; interface ControlProps extends ViewProps { children: ReactNode; callback?: () => void; - controlRef?: RefObject; + controlRef?: RefObject; disabled?: boolean; style?: any; resetControlTimeout?: () => void; diff --git a/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx b/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx index a443a67..2cabd4e 100644 --- a/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx +++ b/src/shared/libs/VideoPlayerControls/components/PlayPause/PlayPause.tsx @@ -5,7 +5,7 @@ import {NullControl} from '../NullControl'; import type {VideoAnimations} from '../../types'; import {styles} from './styles'; -export const playPauseRef = createRef(); +export const playPauseRef = createRef(); interface PlayPauseProps { animations: VideoAnimations; diff --git a/src/shared/libs/luxon/src/impl/zoneUtil.js b/src/shared/libs/luxon/src/impl/zoneUtil.js index c3151a7..f3d1b30 100644 --- a/src/shared/libs/luxon/src/impl/zoneUtil.js +++ b/src/shared/libs/luxon/src/impl/zoneUtil.js @@ -1,7 +1,3 @@ -/** - * @private - */ - import Zone from "../zone.js"; import IANAZone from "../zones/IANAZone.js"; import FixedOffsetZone from "../zones/fixedOffsetZone.js"; diff --git a/src/shared/utils/CommonUtils.ts b/src/shared/utils/CommonUtils.ts index 45a6534..10c66a4 100644 --- a/src/shared/utils/CommonUtils.ts +++ b/src/shared/utils/CommonUtils.ts @@ -65,7 +65,7 @@ export class CommonUtils { static mergeArrays(arr1: Array, arr2: Array, key: string) { let map = new Map(); - arr1.forEach(obj => { + arr1.forEach((obj: any) => { if(!obj[key]) { map.set("" + Date.now() + Math.random(), obj); return; @@ -73,7 +73,7 @@ export class CommonUtils { map.set(obj[key], obj); }); - arr2.forEach(obj => { + arr2.forEach((obj: any) => { if (map.has(obj[key]) && obj[key]) { let mergedObj = this.mergeObjects(map.get(obj[key]), obj); map.set(obj[key], mergedObj); @@ -89,24 +89,24 @@ export class CommonUtils { return Array.from(map.values()); } - static getComponentIdFromMessage(message: CometChat.BaseMessage): Object { - let id = {}; - if (message.receiver instanceof CometChat.User) { - id['uid'] = (message.sender as CometChat.User).uid; - } else if (message.receiver instanceof CometChat.Group) { - id['guid'] = (message.receiver as CometChat.Group).guid; + static getComponentIdFromMessage(message : CometChat.BaseMessage):Object{ + let id: anyObject = {}; + if (message.getReceiver() instanceof CometChat.User) { + id['uid'] = (message.getSender() as any).uid; + } else if (message.getReceiver() instanceof CometChat.Group) { + id['guid'] = (message.getReceiver() as any).guid; } - if (message.parentMessageId && message.parentMessageId !== 0) { - id['parentMessageId'] = message.parentMessageId; + if (message.getParentMessageId() && message.getParentMessageId() !== 0) { + id['parentMessageId'] = message.getParentMessageId(); } return id; } - static checkIdBelongsToThisComponent(id, user: CometChat.User, group: CometChat.Group, parentMessageId: string | number): boolean { - if (id) { - if (id['parentMessageId'] && (id['parentMessageId'] != parentMessageId)) return false - if ((id['uid'] || user) && id['uid'] != user?.uid) return false; - if ((id['guid'] || group) && id['guid'] != group?.guid) return false; + static checkIdBelongsToThisComponent(id: anyObject, user :CometChat.User | any, group: CometChat.Group | any, parentMessageId :string| number): boolean{ + if(id){ + if(id['parentMessageId'] && ( id['parentMessageId'] != parentMessageId ))return false + if((id['uid'] || user) && id['uid'] != user?.uid) return false; + if( (id['guid'] || group) && id['guid'] != group?.guid) return false; } return true; } diff --git a/src/shared/utils/InteractiveMessageUtils.ts b/src/shared/utils/InteractiveMessageUtils.ts index 11d2357..55aea61 100644 --- a/src/shared/utils/InteractiveMessageUtils.ts +++ b/src/shared/utils/InteractiveMessageUtils.ts @@ -24,7 +24,7 @@ export class InteractiveMessageUtils { let completed = false; let neededInteractionElement = interactionGoal?.getElementIds() || []; let neededInteractionElementCondition: string = interactionGoal?.getType() || ""; - let _interactedElements = [...interactedElements] || []; + let _interactedElements = [...(interactedElements ?? [])]; switch (neededInteractionElementCondition) { case goalType.anyOf.toString(): diff --git a/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts b/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts index 8b247e3..acd7894 100644 --- a/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts +++ b/src/shared/views/CometChatActionSheet/ActionSheetStyle.ts @@ -20,15 +20,15 @@ export interface ActionSheetStylesInterface extends BaseStyleInterface { */ export class ActionSheetStyles extends BaseStyle { - layoutModeIconTint: string; - titleFont: FontStyleInterface; - titleColor: string; - listItemIconTint: string; - listItemTitleFont: FontStyleInterface; - listItemTitleColor: string; - listItemIconBackground: string; - listItemIconBorderRadius: number; - actionSheetSeparatorTint: string; + layoutModeIconTint?: string; + titleFont?: FontStyleInterface; + titleColor?: string; + listItemIconTint?: string; + listItemTitleFont?: FontStyleInterface; + listItemTitleColor?: string; + listItemIconBackground?: string; + listItemIconBorderRadius?: number; + actionSheetSeparatorTint?: string; paddingHorizontal?: number; optionsSeparatorTint?:string; /** @@ -56,8 +56,6 @@ export class ActionSheetStyles extends BaseStyle { borderRadius: props.borderRadius, }); if (props) - for (const [key, value] of Object.entries(props)) { - this[key] = value; - } + Object.assign(this, props); } } diff --git a/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx b/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx index 9119388..0e3349e 100644 --- a/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +++ b/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx @@ -54,7 +54,7 @@ export const CometChatAudioBubble = ({ const { theme } = useContext(CometChatContext); const callCount = useRef(0); - const timerId = useRef(null); + const timerId = useRef(null); const threshold = 10; const timeframe = 1000; diff --git a/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx b/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx index 90272b2..b10593f 100644 --- a/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +++ b/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx @@ -42,7 +42,7 @@ export const CometChatFileBubble = ({ const { theme } = useContext(CometChatContext); const callCount = useRef(0); - const timerId = useRef(null); + const timerId = useRef(null); const threshold = 10; const timeframe = 1000; @@ -118,7 +118,7 @@ export const CometChatFileBubble = ({ }; - const wrapperPressTime = useRef(0); + const wrapperPressTime = useRef(0); let viewProps = Platform.OS === "ios" ? { onTouchStart: () => { wrapperPressTime.current = Date.now(); diff --git a/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx b/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx index 9a79548..4172a40 100644 --- a/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx +++ b/src/shared/views/CometChatFormBubble/CometChatFormBubble.tsx @@ -433,7 +433,7 @@ export const CometChatFormBubble = memo((props: CometChatFormBubbleInterface) => let completed = false; let neededInteractionElement = interactionGoal?.getElementIds() || []; let neededInteractionElementCondition: string = interactionGoal?.getType() || ""; - let _interactedElements = [...interactedElements] || []; + let _interactedElements = [...(interactedElements ?? [])]; switch (neededInteractionElementCondition) { case goalType.anyOf.toString(): diff --git a/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx b/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx index d58bb91..04ad636 100644 --- a/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +++ b/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx @@ -62,7 +62,7 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => { const callCount = useRef(0); - const timerId = useRef(null); + const timerId = useRef(null); const threshold = 10; const timeframe = 1000; @@ -232,13 +232,13 @@ export const CometChatImageBubble = (props: CometChatImageBubbleInterface) => { height, width, backgroundColor, - }} + } as ImageStyle} /> : return list; } catch (error: any) { console.log("error while fetching reactions", error) - if (error?.code === "REQUEST_IN_PROGRESS") return; setState("error"); return []; } diff --git a/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx b/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx index 5310727..3f34d7c 100644 --- a/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx +++ b/src/shared/views/CometChatSchedulerBubble/CometChatSchedulerBubble.tsx @@ -426,9 +426,9 @@ export const CometChatSchedulerBubble = memo( } }; - const getQuickSelectSlots = async (date, shouldViewNext = true) => { + const getQuickSelectSlots = async (date: Date, shouldViewNext = true) => { let day = DateTime.fromJSDate(date).toFormat("EEEE"); - date = DateTime.fromJSDate(date).toFormat(dateFormats.date); + let dateString = DateTime.fromJSDate(date).toFormat(dateFormats.date); let newQuickObj: anyObject = {}; getConvertedAvailablityObjectForDate(date, day, newQuickObj); @@ -445,15 +445,15 @@ export const CometChatSchedulerBubble = memo( }); tempQuickSelectRange.current = range; - if (range.length && newQuickObj[date]) { - newQuickObj[date].availability = range; + if (range.length && newQuickObj[dateString]) { + newQuickObj[dateString].availability = range; } // Ensure range is an Array if (!Array.isArray(range)) { range = []; } - if (range.length < 2 && shouldViewNext) await getNextQuickSlots(date, newQuickObj); + if (range.length < 2 && shouldViewNext) await getNextQuickSlots(dateString, newQuickObj); let quickSlotsArray: any[] = []; diff --git a/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx b/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx index 03a0f3d..5d2fe6f 100644 --- a/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +++ b/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx @@ -77,7 +77,7 @@ export const CometChatVideoBubble = (props: CometChatVideoBubbleInterface) => { const [isVideoPlayerVisible, setIsVideoPlayerVisible] = useState(false); const callCount = useRef(0); - const timerId = useRef(null); + const timerId = useRef(null); const threshold = 10; const timeframe = 1000;