fix: improve chat auto-scroll logic, reduce socket timeout, and prevent duplicate message sends
This commit is contained in:
@@ -360,10 +360,15 @@ class _ChatScreenState extends ConsumerState<ChatScreen>
|
||||
orElse: () => null,
|
||||
);
|
||||
|
||||
// Auto-scroll only when a NEW message is added (not on any rebuild)
|
||||
if (messages.length > _previousMessageCount && _previousMessageCount > 0) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scrollToBottom(animated: true);
|
||||
});
|
||||
// Only scroll if user is near the bottom (not scrolled up reading history)
|
||||
if (_scrollController.hasClients &&
|
||||
_scrollController.position.pixels < 150) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) _scrollToBottom(animated: true);
|
||||
});
|
||||
}
|
||||
}
|
||||
_previousMessageCount = messages.length;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user