Skip to content

bug: incorrect channel read states for user #1572

@patconrey

Description

@patconrey

Channels with unread messages are not reliably showing up as unread.

I'd like to show which channels have unread messages. Due to other design constraints, I've implemented my own channel list. In order to show which channels have unread messages on first load, I'm using this function in my channel list:

const fetchUnreadCounts = useCallback(async () => {
        if (chatClient && userId) {
            const response = await chatClient.getUnreadCount(userId);

            const allUnreadChannelIds = response.channels.map((channel: { channel_id: string }) => channel.channel_id.split(":")[1]);
            setUnreadChannelIds(allUnreadChannelIds);
        }
    }, [chatClient, userId]);

For updates to the read state, I'm using client.on((event) => ....

In another part of my application, I'm using this to query for unread messages:

const filter = {
    members: { $in: [user._id] },
    has_unread: true
}
const options = {
    member_limit: 1,
    message_limit: 1,
    watch: true
}
const unreadChannels = await chatClient.queryChannels(filter, {}, options);

So far as I can tell, both of these functions should work (they're used in different parts of the app for different reasons). But, in production, channels with unread messages aren't reliably appearing as unread and don't appear in the results returned by these calls.

Some other helpful context: the channels in question have +1,300 members. A user in one of these channels may be a member of more than 100 other channels.

Not really sure where to go from here. I've tried investigating any pagination problems or limits due to channel size, and I'm coming up short.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions