Skip to main content

Unread message count

Retrieve the total unread message count and unread counts by DND level.

Get total unread count

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

const { code, data: totalUnread } = await BaseChannel.getTotalUnreadCount();
if (code === 0) {
console.log('Total unread:', totalUnread);
} else {
console.log('Failed to get unread count. Code:', code);
}

Get unread count by DND level

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

const { code, data: unreadCount } = await BaseChannel.getChannelsUnreadCountByNoDisturbLevel({
levels: [ChannelNoDisturbLevel.DEFAULT],
channelTypes: [ChannelType.Private, ChannelType.Group],
});
if (code === 0) {
console.log('Unread count:', unreadCount);
}

Parameters

ParameterTypeRequiredDescription
levelsChannelNoDisturbLevel[]YesDND levels to include in the count
channelTypesChannelType[]YesChannel types to include in the count

ChannelNoDisturbLevel values

ValueDescription
ChannelNoDisturbLevel.ALL_MESSAGENotify for all messages
ChannelNoDisturbLevel.DEFAULTDefault notification level (follows global settings)
ChannelNoDisturbLevel.MENTIONNotify on any @mention
ChannelNoDisturbLevel.MENTION_USERSNotify only when mentioned by name
ChannelNoDisturbLevel.MENTION_ALLNotify only on @all mentions
ChannelNoDisturbLevel.MUTEDFully muted — no notifications