Skip to main content

How to use filter state message in Chatroom (React Native)

The LikeMinds Chat SDK provides flexibility to hide or show certain state messages in the chatroom for React Native applications. This guide will help you filter messages on the Chatroom screen.


Enums For Conversation State

EnumStateTypeExample
NORMAL0Normal messageHey
FIRST_CONVERSATION1Chatroom first messageTony Stark started this chatroom
MEMBER_JOINED_OPEN_CHATROOM2Member joins open chatroomTony Stark joined this chatroom
MEMBER_LEFT_OPEN_CHATROOM3Member leaves open chatroomTony Stark left this chatroom
MEMBER_ADDED_TO_CHATROOM7Member added in chatroomNick Fury added Tony Stark
MEMBER_LEFT_SECRET_CHATROOM8Member leaves secret chatroomTony Stark left this chatroom
MEMBER_REMOVED_FROM_CHATROOM9Member is removed from a chatroomNick Fury removed Tony Stark
POLL10Poll messageNick Fury created a poll: "Who should lead the Avengers?"
ALL_MEMBERS_ADDED11All members are added in a chatroomNick Fury added all members
TOPIC_CHANGED12Chatroom topic changedNick Fury changed current topic to "Hey"

Filtering Messages by State

You can filter out the messages you do not wish to show in the chatroom by specifying the states you want to hide. Follow these steps:

  1. Create an array named filterStateMessage.
  2. Add the state values you wish to hide.
  3. Pass this array while creating the instance of the lmChatClient.

Code Example:

import { ConversationState } from "@likeminds.community/chat-rn";
import { initiateLMClient } from "@likeminds.community/chat-rn-core";

// Define the conversation states to filter
// Example Usage
const filterStateMessage = [
ConversationState.MEMBER_JOINED_OPEN_CHATROOM,
ConversationState.MEMBER_LEFT_OPEN_CHATROOM,
];

export const lmChatClient = initiateLMClient(filterStateMessage);