We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d69c30c commit 1f3e929Copy full SHA for 1f3e929
examples/SampleApp/src/components/UnreadCountBadge.tsx
@@ -42,11 +42,13 @@ export const ChannelsUnreadCountBadge: React.FC = () => {
42
if (event.total_unread_count !== undefined) {
43
setUnreadCount(event.total_unread_count);
44
} else {
45
- const countUnread = Object.values(chatClient.activeChannels).reduce(
46
- (count, channel) => count + channel.countUnread(),
47
- 0,
48
- );
49
- setUnreadCount(countUnread);
+ if (Object.keys(chatClient?.activeChannels).length > 0) {
+ const countUnread = Object.values(chatClient.activeChannels).reduce(
+ (count, channel) => count + channel.countUnread(),
+ 0,
+ );
50
+ setUnreadCount(countUnread);
51
+ }
52
}
53
});
54
0 commit comments