groupChannelCollection. Possible to reverse the results?


Is it possible from the API to fetch group channels with selected ordering in ascending order? So that you get the channels with latest oldest last message sent first in the array of channels?
Obviously, that could be done client side, but that would make pagination a lot more complicated when there are more than 100 channels.

The message list API does provide a ‘reverse’ / ascending option.

  const groupChannelFilter = new sb.GroupChannelFilter();
  groupChannelFilter.includeEmpty = true;
  groupChannelFilter.includeMetaData = true;
  groupChannelFilter.includeFrozen = true;

  const groupChannelCollection = sb.GroupChannel.createGroupChannelCollection()
    // note: 100 is max per query. If you have more than 100 channels,
    // and reverse the channels client side, that will be problematic.

  if (groupChannelCollection.hasMore) {
    groupChannelCollection.loadMore().then((channels) => {
      console.log('channels fetched!', channels)


So you are right on GroupChannel there is no reverse() call like there is when listing messages. For your usecase, will there be many instances in which your users will need to have more than 100 channels listed in a given instance? If you dont intended to have thousands of channels maybe low 100s you could implement a check before displaying the list. Once you get back the returned result call .hasNext() if it returns true just add it to your list before doing a client side reverse. For 100-200 channels it shouldn’t be a significant delay.

In the event you plan to have high hundreds to thousands can I ask how you would want to display them? Or if it would be of benefit to make the UX a little better by hiding certain channels.

Either way if you could describe your usecase a little more and the desired UX we might be able to help you find the optimal solution!

@Alex_Preston, thanks for the response.

The reason I asked is that I was afraid I was missing the reverse feature. It seems logical that it should be provided when querying channels as well. I feel it’s pretty common users would want to sort their channels from old to new.

The UI would be something similar to a channel list on the left, like the base UIKIt design, with custom grouping of channels, where you can drag the channels into those folders, and expand / collapse those folders.

Like slack, but the channel list would still be a full ‘channel preview’, including last message sent and timestamp.


We do expect a high number of channels, eventually.

Having said this, you could query those folders once you expand them.


You are not missing the reverse feature, we do not have that built in to channel listing. The thought process is generally customers who want chat want a similar experience to industry standards. Newest to oldest(you can list channels by chronological). The reason why messageList has that ability is because of whether or not you want messages to be top to bottom or bottom to top. Generally our customers who want to reverse will do a client side reverse. From what I have seen they do something similar to what you have above. If there is more than 100 channels they will break them up. As more than 100 channels becomes alot to look through without better ordering.

I think your approach of not querying until they expand the folder is the correct approach. This should help you be able to limit the number of channels in a given query so a client side reverse is easy enough.

1 Like