Skip to content

Commit 7145e19

Browse files
committed
msglist: Autofocus compose box only when the whole history is empty
Previously, if the initial batch came up empty, then the history was considered empty too. But now, the initial batch could be empty because of the messages in muted conversations while there may still be other messages in history.
1 parent a3065ec commit 7145e19

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/widgets/message_list.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
895895
model.fetchInitial();
896896
}
897897

898-
bool _prevFetched = false;
898+
bool _hasAutofocused = false;
899899

900900
void _modelChanged() {
901901
// When you're scrolling quickly, our mark-as-read requests include the
@@ -945,14 +945,14 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
945945
_fetchMoreIfNeeded(scrollController.position);
946946
});
947947

948-
if (!_prevFetched && model.fetched && model.messages.isEmpty) {
949-
// If the fetch came up empty, there's nothing to read,
950-
// so opening the keyboard won't be bothersome and could be helpful.
948+
if (model.messages.isEmpty && model.haveNewest && model.haveOldest && !_hasAutofocused) {
949+
// If there are no messages to show in the whole history,
950+
// opening the keyboard won't be bothersome and could be helpful.
951951
// It's definitely helpful if we got here from the new-DM page.
952952
MessageListPage.ancestorOf(context)
953953
.composeBoxState?.controller.requestFocusIfUnfocused();
954+
_hasAutofocused = true;
954955
}
955-
_prevFetched = model.fetched;
956956
}
957957

958958
/// Find the range of message IDs on screen, as a (first, last) tuple,

0 commit comments

Comments
 (0)