Get Unread Chatrooms
The getUnreadChatrooms
function retrieves a list of unread chatrooms from the local database using Realm. It accepts a Chatroom
and the lastConversation
as input, updating or creating relevant records within the local database. If the chatroom exists, it updates the unseenCount
, unreadConversationsCount
, and conversation details. If the chatroom is not found, it creates new chatroom, conversation, and member records. The method filters chatrooms with active follow status, no mute status, and unseen messages, then sorts them by the latest conversation timestamp. It returns a maximum of 7 chatrooms wrapped in an LMResponse
.
Fetch a single chatroom
- To fetch the unread chatrooms, use the
getUnreadChatrooms()
method of thelmChatClient
you initialised. - Pass in the required parameter.
- Process the response as per your requirement.
const payload = {
chatroom: "ENTER_YOUR_CHATROOM_OBJECT",
lastConversation: "ENTER_YOUR_LAST_CONVERSATION_OBJECT",
};
const response = await lmChatClient.getUnreadChatrooms(payload).data;
if (response.success) {
// your function to process the response data
processResponse(response);
} else {
// your function to process error message
processError(response);
}
Get Unread Chatroom Payload
List of parameters supported.
Variable | Type | Description | Optional |
---|---|---|---|
chatroom | Chatroom | Information about the chatroom | |
lastConversation | Conversation | Information about the last conversation |
Get Unread Chatroom Response
List of parameters in the response.
Variable | Type | Description |
---|---|---|
chatroom | Chatroom | Details of chatroom |