Channel is not appear after creating

When a user creates a new channel and there are no messages there yet, the channel is simply not displayed.
Our steps:
The user creates a channel - adds users - returns to the chat - returns to the chat list - this channel is not in the channel list.
Neither restart nor re-enter the channel list helps.
Our Activity just extends Sendbird ChannelListActivity.

Hey @Jamworks,

Can you confirm that your query has .setIncludeEmpty(true)? if you do not have that by default empty channels wont be returned.

Where we should put it, if our activity just extend your ChannelListActivity and nothing more?
Снимок экрана 2022-01-10 в 11.56.40

@Jamworks,

So it will actually be in your ChannelListFragment.Builder() if you have access to our sample it will be in GroupChannelMainActivity.java. Essentially it will look something like this:

return new ChannelListFragment.Builder(R.style.CustomChannelListStyle)
                        .setCustomChannelListFragment(new CustomChannelListFragment())
                        .setUseHeader(false)
                        .setHeaderTitle(null)
                        .setUseHeaderLeftButton(true)
                        .setUseHeaderRightButton(true)
                        .setHeaderLeftButtonIconResId(R.drawable.icon_arrow_left)
                        .setHeaderRightButtonIconResId(R.drawable.icon_create)
                        .setHeaderLeftButtonListener(null)
                        .setHeaderRightButtonListener(null)
                        .setChannelListAdapter(new CustomChannelListAdapter())
                        .setItemClickListener((view, i, channel) -> showCustomChannelActivity(channel.getUrl()))
                        .setItemLongClickListener(null)
                        .setGroupChannelListQuery(null)
                        .build();

Youll see the .setGroupChannelListQuery(), pass in a query there! Here is the documentation showing a bit more.

Sorry, but I didn’t get.
Where should I insert your code above in my activity which just extend ChannelListActivity? (as on screenshot)

@Jamworks,

Have you referenced our Sample App? If so the example is in the GroupChannelMainActivity.java, if you have not see this I recommend checking it out!

With that said it looks like you are not implementing your custom Activities/Fragments. This will be why you cannot add a custom query. I would recommend checking out the above sample as well as the documentation I listed above. Essentially when you do implement the custom Activities you will potentially launch it by doing something like what I put here. You can see where you set the GroupChannelListQuery(). Let me know if you have any questions about this!

Yes, I saw the repository and the tutorial.
Do I understand you correctly that I need to use the activity as in the example(GroupChannelMainActivity), and not ChannelListActivity? Why? In which cases I need to use ChannelListActivity?

@Jamworks,

I dont fully understand what you mean could you clarify a bit more? If you wish to customize each Activity I would extend those activities on your own. Same with the fragments.

I guess what Alex recommends is something like:

  1. Show channel list in the UIKit
        ChannelListFragment fragment = createChannelListFragment();
        ...

And the function for creating the ChannelListFragment would be something like:

    protected ChannelListFragment createChannelListFragment() {
        // This is what you have to add to see the empty channels
        GroupChannelListQuery query = GroupChannel.createMyGroupChannelListQuery();
        query.setIncludeEmpty(true);
        // Then return it
        return new ChannelListFragment.Builder()
                .setUseHeader(true)
                .setGroupChannelListQuery(query)
                    .build();
    }

Thanks!
This fragment should be in my activity which extends ChannelListActivty?

@Jamworks not entirely. The above that @walter.rodriguez is showing is how to build the channelListFragment. It should be in the activity where you want to launch chat from. Like how this activity does it.

For those who needs it.

public class ChannelsActivity extends ChannelListActivity {

    @NonNull
    @Override
    protected Fragment createFragment() {
        // Overridden to show empty Group Channels that are hidden by default
        GroupChannelListQueryParams params = new GroupChannelListQueryParams();
        params.setIncludeEmpty(true);

        return new ChannelListFragment.Builder()
                .withArguments(new Bundle())
                .setUseHeader(true)
                .setGroupChannelListQuery(GroupChannel.createMyGroupChannelListQuery(params))
                .build();
    }
}
1 Like