From 8ee4b585b8d80e3096e1f3c7b68d7f8c706136f4 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 18 Dec 2020 10:00:10 +0100 Subject: [PATCH] mark read only if the channel is up to date --- lib/src/message_list_view.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/message_list_view.dart b/lib/src/message_list_view.dart index 254af757..6d1e61f2 100644 --- a/lib/src/message_list_view.dart +++ b/lib/src/message_list_view.dart @@ -511,6 +511,7 @@ class _MessageListViewState extends State { _bottomPaginationActive = false; _topPaginationActive = false; streamChannel.reloadChannel(); + streamChannel.channel.markRead(); } else { setState(() => _showScrollToBottom = false); _scrollController.scrollTo( @@ -642,7 +643,8 @@ class _MessageListViewState extends State { onVisibilityChanged: (visibility) { final isVisible = visibility.visibleBounds != Rect.zero; if (isVisible && !_bottomWasVisible) { - if (streamChannel.channel.config?.readEvents == true && + if (streamChannel.channel.state.isUpToDate && + streamChannel.channel.config?.readEvents == true && streamChannel.channel.state.unreadCount > 0) { streamChannel.channel.markRead(); }