diff --git a/CHANGELOG.md b/CHANGELOG.md index 62efc4ac..c91502be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.17+2 + +- Expose ChannelsBloc.channelsComparator to sort channels on message.new event + ## 0.2.17+1 - Fix mention tap bug diff --git a/lib/src/channels_bloc.dart b/lib/src/channels_bloc.dart index 3af2300d..59dd6335 100644 --- a/lib/src/channels_bloc.dart +++ b/lib/src/channels_bloc.dart @@ -14,11 +14,15 @@ class ChannelsBloc extends StatefulWidget { /// Set this to true to prevent channels to be brought to the top of the list when a new message arrives final bool lockChannelsOrder; + /// Comparator used to sort the channels when a message.new event is received + final Comparator channelsComparator; + /// Instantiate a new ChannelsBloc const ChannelsBloc({ Key key, this.child, this.lockChannelsOrder = false, + this.channelsComparator, }) : super(key: key); @override @@ -141,6 +145,10 @@ class ChannelsBlocState extends State } } } + + if (widget.channelsComparator != null) { + newChannels.sort(widget.channelsComparator); + } _channelsController.add(newChannels); })); } diff --git a/pubspec.yaml b/pubspec.yaml index a400260e..dd5273b7 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.17+1 +version: 0.2.17+2 repository: https://github.com/GetStream/stream-chat-flutter issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues