Merge pull request #233 from GetStream/feature/messageFilter
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
## 0.2.21
|
||||
|
||||
- Add `loadingBuilder` in `MessageListView`
|
||||
- Add `messageFilter` property in `MessageListView`
|
||||
|
||||
## 0.2.20+4
|
||||
|
||||
- Fix channelPreview when the message list is empty
|
||||
|
||||
@@ -59,7 +59,7 @@ void _initNotifications(Client client) {
|
||||
if (connector.token.value != null) {
|
||||
client.addDevice(
|
||||
connector.token.value,
|
||||
Platform.isAndroid ? 'firebase' : 'apn',
|
||||
Platform.isAndroid ? PushProvider.firebase : PushProvider.apn,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -127,7 +127,7 @@ class ChannelListPage extends StatelessWidget {
|
||||
'\$in': [StreamChat.of(context).user.id],
|
||||
}
|
||||
},
|
||||
// sort: [SortOption('last_message_at')],
|
||||
sort: [SortOption('last_message_at')],
|
||||
pagination: PaginationParams(
|
||||
limit: 20,
|
||||
),
|
||||
|
||||
@@ -108,6 +108,8 @@ class MessageListView extends StatefulWidget {
|
||||
this.onParentMessageTap,
|
||||
this.scrollPhysics = const AlwaysScrollableScrollPhysics(),
|
||||
this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
|
||||
this.messageFilter,
|
||||
this.loadingBuilder,
|
||||
}) : super(key: key);
|
||||
|
||||
/// Function used to build a custom message widget
|
||||
@@ -119,6 +121,12 @@ class MessageListView extends StatefulWidget {
|
||||
/// Function used to build a custom thread widget
|
||||
final ThreadBuilder threadBuilder;
|
||||
|
||||
/// The builder used while loading.
|
||||
final WidgetBuilder loadingBuilder;
|
||||
|
||||
/// Filter applied to the message list before rendering
|
||||
final bool Function(Message) messageFilter;
|
||||
|
||||
/// Function called when tapping on a thread
|
||||
/// By default it calls [Navigator.push] using the widget built using [threadBuilder]
|
||||
final ThreadTapCallback onThreadTap;
|
||||
@@ -304,6 +312,11 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
if (!snapshot.data) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
if (widget.loadingBuilder != null) {
|
||||
return widget.loadingBuilder(context);
|
||||
}
|
||||
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@@ -518,15 +531,20 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
.map((threads) => threads[widget.parentMessage.id]);
|
||||
}
|
||||
|
||||
_streamListener = stream
|
||||
.map((messages) =>
|
||||
messages
|
||||
?.where((m) =>
|
||||
!(m.status == MessageSendingStatus.FAILED && m.isDeleted) &&
|
||||
m.shadowed != true)
|
||||
?.toList() ??
|
||||
[])
|
||||
.listen((newMessages) {
|
||||
_streamListener = stream.map((messages) {
|
||||
final filteredMessages = messages
|
||||
?.where((m) =>
|
||||
!(m.status == MessageSendingStatus.FAILED && m.isDeleted) &&
|
||||
m.shadowed != true)
|
||||
?.toList() ??
|
||||
[];
|
||||
|
||||
if (widget.messageFilter != null) {
|
||||
return messages.where(widget.messageFilter).toList();
|
||||
}
|
||||
|
||||
return filteredMessages;
|
||||
}).listen((newMessages) {
|
||||
newMessages = newMessages.reversed.toList();
|
||||
if (_messages.isEmpty ||
|
||||
newMessages.isEmpty ||
|
||||
|
||||
+1
-1
@@ -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+4
|
||||
version: 0.2.21
|
||||
repository: https://github.com/GetStream/stream-chat-flutter
|
||||
issue_tracker: https://github.com/GetStream/stream-chat-flutter/issues
|
||||
|
||||
|
||||
Reference in New Issue
Block a user