Exclude empty channels and pagination

I’m trying to fetch non-empty group channels by setting the includeEmpty option to false.

The channels that never had messages did successfully get excluded.

But I noticed if I go to a channel that has some messages and delete all the messages, making it “empty”, that channel will still be returned in the list.

Not sure if it is intended. And if it is, how does SendBird determine whether a channel is really “empty”?

Another question:
What’s the better way to do pagination and why? GroupChannelListQuery or GroupChannelCollection?
I’ve tried both and both works.

Thank you.

Hey @hewong

I believe that the check is based on lastMessage. Let me run a check to see if you delete all messages if channel.lastMessage is also null or if that reference is missed when deleting.

I believe both will work. Collection is in reference to the SyncManager. You can read more about it here:

Local caching operates on the groupChannelCollection and messageCollection classes, which are used to build a channel list and a chat view, respectively.

Hi, is there any updates regarding the investigation on empty channels?

I did a comparison between two empty channels (one was returned even when includeEmpty is set to false, and another one correctly gets excluded). Both channels has their lastMessages set to null, I couldn’t really see what makes them behave differently…

Could you please help finding out the reason please?

Any updates on the empty channels please?

Can you show me the query?

I am testing on the latest version and upon deleting last message in the channel to make it an empty channel it becomes channel.lastMessage = null.

Here’s the code I’m using currently

const order = this.sb.GroupChannelCollection.GroupChannelOrder.LATEST_LAST_MESSAGE;
const limit = 50;
const filter = new this.sb.GroupChannelFilter();
filter.includeEmpty = false;
filter.memberStateFilter = 'joined_only';


I’ve also tried with the GroupChannelListQuery, doesn’t seems to make a difference

const listQuery = this.sb.GroupChannel.createMyGroupChannelListQuery();
listQuery.includeEmpty = false;
listQuery.memberStateFilter = 'joined_only';
listQuery.order = 'latest_last_message';
listQuery.limit = 50;


Have you tested this on our sample app? Your query does look correct.

As a follow up question. Do you even want to still use that channel that had all messages deleted? Or would you ideally like it to be gone? If so you could mark that channel as hidden.

Actually, I’d just like to understand if what I’m encountering (empty channels being returned after all messages deleted) is an intended behaviour or an unintended bug.

If it’s intended, meaning includeEmpty does not determine whether the channel is “empty” based on the lastMessage property, since it’s null in both cases (originally empty channel and manually made empty channel).

Really just wanted to understand whether it’s intended and how the includeEmpty param works. I know how I could handle it if it’s intended.

Thank you.

I would say it doesnt seem like intended behavior. I would have to think there might be something wrong with the given channel. If you want to dm me the channel I can take a look further. Based on my tests with the sample app I was not able to reproduce the issue.