Skip to main content

Overview

CometChatConversations is a component that displays all conversations associated with the currently logged-in user.

Usage

Integration

To use Conversations in your component, use the following code snippet:
App.tsx

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.
onItemPress
Function executed when an item is long-pressed in the conversation list, commonly used to initiate actions like delete, selection, or entering multi-select mode.

onItemLongPress
Function executed when a conversation item is long-pressed, allowing additional actions like delete or select.

onBack
onBack is triggered when you press the back button in the app bar. It does not have a default behavior. However, you can override its behavior using the following code snippet.

onSelection
Called when a item from the fetched list is selected useful for multi-selection features.

OnError
This action doesn’t change the behavior of the component but rather listens for any errors that occur in the Conversations component.

onEmpty
Called when the list is empty, enabling custom handling such as showing a placeholder message

onLoad
Invoked when the list is successfully fetched and loaded, helping track component readiness.

onSubmit
Called when submit selection button is pressed.

Filters

You can set ConversationsRequestBuilder in the Conversations Component to filter the conversation list. You can modify the builder as per your specific requirements with multiple options available to know more refer to ConversationRequestBuilder. You can set filters using the following parameters.
  1. Conversation Type: Filters on type of Conversation, User or Groups
  2. Limit: Number of conversations fetched in a single request.
  3. WithTags: Filter on fetching conversations containing tags
  4. Tags: Filters on specific Tag
  5. UserTags: Filters on specific User Tag
  6. GroupTags: Filters on specific Group Tag

Events

Events are emitted by a Component. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.
1. ConversationDeleted
This event will be emitted when the user deletes a conversation

Customization

To fit your app’s design requirements, you can customize the appearance of the conversation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.
Style
You can pass a styling object as a prop to the CometChatConversations component to customize its styling.

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.
Below is a list of customizations along with corresponding code snippets

Advanced

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.

disableSoundForMessages

This method disables sound notifications for incoming messages. When activated, the application will not play an audio alert when new messages arrive. This feature is beneficial in scenarios where:
  • Users prefer a silent messaging experience
  • The app is being used in a professional or quiet environment
  • Background processes need to minimize distractions
By providing this option, the app allows users to tailor their notification preferences.

customSoundForMessages

This method enables users to personalize their chat experience by setting a custom sound file for incoming message notifications. Users can choose from:
  • Default system sounds
  • Custom sound files uploaded by the user
  • Theme-based or brand-specific notification sounds
By allowing sound customization, this feature enhances personalization and improves user engagement.

LoadingView

This method allows developers to set a custom loading view that is displayed when data is being fetched or loaded within the component. Instead of using a default loading spinner, a custom animation, progress bar, or branded loading screen can be displayed. Use cases:
  • Showing a skeleton loader for conversations while data loads
  • Displaying a custom progress indicator with branding
  • Providing an animated loading experience for a more engaging UI

EmptyView

Configures a custom view to be displayed when there are no conversations or messages in the list. This improves the user experience by providing meaningful content instead of an empty screen. Examples:
  • Displaying a message like “No conversations yet. Start a new chat!”
  • Showing an illustration or animation to make the UI visually appealing
  • Providing a button to start a new conversation

ErrorView

Defines a custom error state view that appears when an issue occurs while loading conversations or messages. This enhances the user experience by displaying friendly error messages instead of generic system errors. Common use cases:
  • Showing “Something went wrong. Please try again.” with a retry button
  • Displaying a connection issue message if the user is offline
  • Providing troubleshooting steps for the error

LeadingView

Allows setting a custom leading view element that appears at the beginning of each conversation item. This is typically used to modify profile pictures, avatars, or icons in the conversation list. Examples:
  • Displaying user avatars with online/offline status indicators
  • Using initials or custom graphics instead of images

TitleView

Overrides the default title view in the conversation list with a custom layout. This is useful for branding or modifying how conversation names and details are displayed. Examples:
  • Displaying conversation titles with additional metadata (e.g., last seen time)
  • Custom fonts or text styles for conversation names
  • Adding icons or indicators next to titles
Demonstration

TrailingView

Customizes the trailing (end) view of a conversation item, which is typically used for action buttons or additional information. Examples:
  • Adding a mute/unmute button for each conversation
  • Displaying the last message time in a custom format
  • Showing unread message counts or notification badges
Demonstration

ItemView

This function allows developers to assign a completely custom list item design to the Conversations Component, replacing the default layout. Use cases:
  • Implementing a unique conversation list design with custom styling
  • Adding extra elements like swipe gestures, priority indicators, or group labels
  • Fully customizing how messages are displayed in the list
Demonstration

TextFormatters

This method enables developers to define and apply text formatters that dynamically modify or transform message content before rendering it in the UI. Text formatters can be used for purposes such as:
  • Automatically converting URLs into clickable links
  • Applying Markdown or rich text styling
  • Replacing certain words or patterns with emojis or predefined text
  • Censoring specific words for moderation
By utilizing this method, developers can enhance readability, usability, and compliance with content guidelines. MentionsFormatter Guide Example

AppBarOptions

You can set Custom AppBarOptions to the CometChatConversations widget. Use Cases:
  • Archive Chat
  • Mark All as Read
  • Delete Conversations
Demonstration

DatePattern

This method customizes the date format used for displaying timestamps in conversations or chat components. Developers can specify formats such as:
  • dd/MM/yyyy HH:mm → Example: 10/07/2024 14:30
  • MMM dd, yyyy → Example: Jul 10, 2024
  • hh:mm a → Example: 02:30 PM
Custom date patterns improve the localization and readability of time-sensitive messages, catering to different regional preferences.
Demonstration

SubtitleView

The SubtitleView method allows developers to customize the subtitle view of each conversation item in the list. The subtitle typically displays additional information below the conversation title, such as the last message, message status, or other relevant details. Use Cases:
  • Customizing the Last Message Display – Modify how the last message appears, including text styling, truncation, or emoji support.
  • Message Status Indicators – Show message status (e.g., Sent, Delivered, Read) alongside the last message.
  • Typing Indicators – Display “User is typing…” in real time.
Demonstration

options

This method sets a predefined list of actions that users can perform when they long press a conversation in the list. These options typically include: Use Cases:
  • Deleting a conversation
  • Marking a conversation as read or unread
  • Pinning or unpinning a conversation
  • Muting notifications for a specific conversation
By customizing these options, developers can provide a streamlined and contextually relevant user experience.
Demonstration

addOptions

This method extends the default set of actions triggered when a user long-presses a conversation item. Unlike setOptions, which replaces the existing options, addOptions allows developers to append additional actions while retaining the default ones. Use Cases:
  • Adding a “Report Spam” action
  • Introducing a “Save to Notes” option
  • Integrating third-party actions such as “Share to Cloud Storage”
This method provides flexibility in modifying user interaction capabilities.
Demonstration