diff --git a/CHANGELOG.md b/CHANGELOG.md index a84842c6..8ca3aa04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.20+2 + +- Added `shouldAddChannel` to ChannelsBloc in order to check if a channel has to be added to the list when a new message arrives + ## 0.2.20+1 - Fixed bug that caused video attachment to show the same preview diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index 0784cb30..81081051 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -17,12 +17,16 @@ class ChannelsBloc extends StatefulWidget { /// Comparator used to sort the channels when a message.new event is received final Comparator channelsComparator; + /// Function used to evaluate if a channel should be added to the list when a message.new event is received + final bool Function(Event) shouldAddChannel; + /// Instantiate a new ChannelsBloc const ChannelsBloc({ Key key, this.child, this.lockChannelsOrder = false, this.channelsComparator, + this.shouldAddChannel, }) : super(key: key); @override @@ -128,7 +132,8 @@ class ChannelsBlocState extends State final channel = newChannels.removeAt(index); newChannels.insert(0, channel); } - } else { + } else if (widget.shouldAddChannel != null && + widget.shouldAddChannel(e)) { final hiddenIndex = _hiddenChannels.indexWhere((c) => c.cid == e.cid); if (hiddenIndex > -1) { newChannels.insert(0, _hiddenChannels[hiddenIndex]); diff --git a/pubspec.yaml b/pubspec.yaml index 381830f5..7aac0211 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: stream_chat_flutter homepage: https://github.com/GetStream/stream-chat-flutter description: Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter. -version: 0.2.20+1 +version: 0.2.20+2 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues