Fix chat scrolling & tap to unfocus emote menu
This commit is contained in:
parent
3297c18468
commit
412d1e9211
2 changed files with 10 additions and 3 deletions
|
|
@ -45,7 +45,10 @@ class _ChatState extends State<Chat> {
|
|||
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -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).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue