onChannelVisible method
Function which gets called for the event EventType.channelVisible.
This event is fired when a channel is made visible.
By default, this adds the channel to the list of channels.
Implementation
void onChannelVisible(
Event event,
StreamChannelListController controller,
) async {
final channelId = event.channelId;
final channelType = event.channelType;
if (channelId == null || channelType == null) return;
final channel = await controller.getChannel(
id: channelId,
type: channelType,
);
final currentChannels = [...controller.currentItems];
final updatedChannels = [
channel,
...currentChannels..removeWhere((it) => it.cid == channel.cid),
];
controller.channels = updatedChannels;
}