diff --git a/lib/screens/channel/chat/chat.dart b/lib/screens/channel/chat/chat.dart index 2dcb53a1..20e53d5e 100644 --- a/lib/screens/channel/chat/chat.dart +++ b/lib/screens/channel/chat/chat.dart @@ -45,7 +45,10 @@ class _ChatState extends State { if (message.user != null && message.user != chatStore.auth.user.details?.login) { return InkWell( - onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + if (chatStore.assetsStore.showEmoteMenu) chatStore.assetsStore.showEmoteMenu = false; + }, onLongPress: () => showModalBottomSheet( context: context, builder: (context) => ChatUserModal( diff --git a/lib/screens/channel/chat/chat_store.dart b/lib/screens/channel/chat/chat_store.dart index b89eb165..196c413f 100644 --- a/lib/screens/channel/chat/chat_store.dart +++ b/lib/screens/channel/chat/chat_store.dart @@ -16,6 +16,8 @@ part 'chat_store.g.dart'; class ChatStore = _ChatStoreBase with _$ChatStore; abstract class _ChatStoreBase with Store { + static const _messageLimit = 5555; + /// The provided auth store to determine login status, get the token, and use the headers for requests. final AuthStore auth; @@ -148,9 +150,9 @@ abstract class _ChatStoreBase with Store { continue; } - if (_messages.length >= 5000) _messages.removeAt(0); - if (_autoScroll) { + if (_messages.length >= _messageLimit) _messages.removeAt(0); + SchedulerBinding.instance?.addPostFrameCallback((_) { if (scrollController.hasClients) scrollController.jumpTo(scrollController.position.maxScrollExtent); }); @@ -184,6 +186,8 @@ abstract class _ChatStoreBase with Store { /// Re-enables [_autoScroll] and jumps to the latest message. @action void resumeScroll() { + if (_messages.length >= _messageLimit) _messages.removeRange(0, _messages.length - _messageLimit); + _autoScroll = true; // Jump to the latest message (bottom of the list/chat).