Skip to main content

Unread message list is not available on Web

The current Web Chat SDK does not expose a client API to retrieve the unread message list for a community subchannel.

Get recent messages

TypeScript
import { CommunitySubChannel, BaseChannel } from '@nexconn/chat';

const channel = new CommunitySubChannel('<communityId>', '<subChannelId>');

// Retrieve recent messages from the server
const query = BaseChannel.createMessagesQuery({
channelIdentifier: channel.identifier,
startTime: Date.now(),
pageSize: 20,
isAscending: false,
});
const { isOk, data } = await query.loadNextPage();
if (isOk) {
console.log('Recent messages:', data.data);
}

Get unread count

To get the number of unread messages without fetching their content:

TypeScript
const { isOk, data: newInstance } = await channel.reload();
console.log('Unread count': newInstance.unreadCount);

Clear unread count after reading

After the user reads messages, clear the unread count:

TypeScript
const { code } = await channel.clearUnreadCount();
if (code === 0) {
console.log('Unread count cleared');
}