add paginationLimit to message list core and ui package
This commit is contained in:
@@ -2309,6 +2309,7 @@ class __PickerWidgetState extends State<_PickerWidget> {
|
||||
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
print('on tap');
|
||||
PhotoManager.openSetting();
|
||||
},
|
||||
child: Container(
|
||||
|
||||
@@ -166,11 +166,15 @@ class MessageListView extends StatefulWidget {
|
||||
this.showFloatingDateDivider = true,
|
||||
this.threadSeparatorBuilder,
|
||||
this.messageListController,
|
||||
this.paginationLimit = 20,
|
||||
}) : super(key: key);
|
||||
|
||||
/// Function used to build a custom message widget
|
||||
final MessageBuilder? messageBuilder;
|
||||
|
||||
/// Limit used during pagination
|
||||
final int paginationLimit;
|
||||
|
||||
/// Function used to build a custom system message widget
|
||||
final SystemMessageBuilder? systemMessageBuilder;
|
||||
|
||||
@@ -328,6 +332,7 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => MessageListCore(
|
||||
paginationLimit: widget.paginationLimit,
|
||||
messageFilter: widget.messageFilter,
|
||||
loadingBuilder: widget.loadingBuilder ??
|
||||
(context) => const Center(
|
||||
@@ -640,7 +645,9 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
);
|
||||
|
||||
Future<void> _paginateData(
|
||||
StreamChannelState? channel, QueryDirection direction) =>
|
||||
StreamChannelState? channel,
|
||||
QueryDirection direction,
|
||||
) =>
|
||||
_messageListController.paginateData!(direction: direction);
|
||||
|
||||
int? _getTopElementIndex(Iterable<ItemPosition> values) {
|
||||
|
||||
@@ -71,6 +71,7 @@ class MessageListCore extends StatefulWidget {
|
||||
this.parentMessage,
|
||||
this.messageListController,
|
||||
this.messageFilter,
|
||||
this.paginationLimit = 20,
|
||||
}) : super(key: key);
|
||||
|
||||
/// A [MessageListController] allows pagination.
|
||||
@@ -86,6 +87,9 @@ class MessageListCore extends StatefulWidget {
|
||||
/// Function used to build an empty widget
|
||||
final WidgetBuilder emptyBuilder;
|
||||
|
||||
/// Limit used to paginate messages
|
||||
final int paginationLimit;
|
||||
|
||||
/// Callback triggered when an error occurs while performing the given
|
||||
/// request.
|
||||
///
|
||||
@@ -163,13 +167,20 @@ class MessageListCoreState extends State<MessageListCore> {
|
||||
/// Fetches more messages with updated pagination and updates the widget.
|
||||
///
|
||||
/// Optionally pass the fetch direction, defaults to [QueryDirection.top]
|
||||
/// Optionally pass a limit, defaults to 20
|
||||
Future<void> paginateData({
|
||||
QueryDirection direction = QueryDirection.top,
|
||||
}) {
|
||||
if (!_isThreadConversation) {
|
||||
return _streamChannel!.queryMessages(direction: direction);
|
||||
return _streamChannel!.queryMessages(
|
||||
direction: direction,
|
||||
limit: widget.paginationLimit,
|
||||
);
|
||||
} else {
|
||||
return _streamChannel!.getReplies(widget.parentMessage!.id);
|
||||
return _streamChannel!.getReplies(
|
||||
widget.parentMessage!.id,
|
||||
limit: widget.paginationLimit,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +190,10 @@ class MessageListCoreState extends State<MessageListCore> {
|
||||
|
||||
if (newStreamChannel != _streamChannel) {
|
||||
if (_streamChannel == null /*only first time*/ && _isThreadConversation) {
|
||||
newStreamChannel.getReplies(widget.parentMessage!.id);
|
||||
newStreamChannel.getReplies(
|
||||
widget.parentMessage!.id,
|
||||
limit: widget.paginationLimit,
|
||||
);
|
||||
}
|
||||
_streamChannel = newStreamChannel;
|
||||
}
|
||||
@@ -197,7 +211,10 @@ class MessageListCoreState extends State<MessageListCore> {
|
||||
|
||||
if (widget.parentMessage?.id != widget.parentMessage?.id) {
|
||||
if (_isThreadConversation) {
|
||||
_streamChannel!.getReplies(widget.parentMessage!.id);
|
||||
_streamChannel!.getReplies(
|
||||
widget.parentMessage!.id,
|
||||
limit: widget.paginationLimit,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,9 +147,18 @@ class StreamChannelState extends State<StreamChannel> {
|
||||
}
|
||||
|
||||
/// Calls [channel.query] updating [queryMessage] stream
|
||||
Future<void> queryMessages({QueryDirection? direction = QueryDirection.top}) {
|
||||
if (direction == QueryDirection.top) return _queryTopMessages();
|
||||
return _queryBottomMessages();
|
||||
Future<void> queryMessages({
|
||||
QueryDirection? direction = QueryDirection.top,
|
||||
int limit = 20,
|
||||
}) {
|
||||
if (direction == QueryDirection.top) {
|
||||
return _queryTopMessages(
|
||||
limit: limit,
|
||||
);
|
||||
}
|
||||
return _queryBottomMessages(
|
||||
limit: limit,
|
||||
);
|
||||
}
|
||||
|
||||
/// Calls [channel.getReplies] updating [queryMessage] stream
|
||||
|
||||
Reference in New Issue
Block a user