How to fetch all public super group channels another user is a part of client side

Hello.

We have the following use case.
User A is logged in client side. User A wants to fetch a list of all public super group channels user B is part of (joined / member).

Using PublicGroupChannelListQuery, we can fetch a list of all public supergroup channels. However, in JS SDK, there is no option to filter the rooms by specific joined member ids.

Another attempt we tried, is to filter client side by the members array. However, we discovered the members array is limited to max 10 members, even if the channel has more than 10 members.

image

Can we achieve this use case client side, without using another backend to call the Platform API’s List channels API call?

Hi @vibonacci,

You should be able to filter the supergroup channels by using userIdsIncludeFilter as shown below. More information can be found here, Group channel | Chat JavaScript SDK | Sendbird Docs.

var channelListQuery = sendbird.GroupChannel.createPublicGroupChannelListQuery();
channelListQuery.userIdsIncludeFilter = ['UserB'];

For supergroup channels only the first 10 members are returned with the channel. To get all the members of a supergroup channel you need to create a MemberListQuery.

var memberListQuery = groupChannel.createMemberListQuery();
memberListQuery.limit = 10; // Max value is 100 members returned per page

if (memberListQuery.hasNext) {
    memberListQuery.next(function(users, error) {
        if (error) {
            // Handle error.
        }
        users.forEach(user => {
            // Handle user object
        })
    });
}
3 Likes

Thank you for the response.
Using the memberListQuery, we can achieve it client side.