commit 21766c95356e4b92c78213a399dec16fd52c31be
parent 15f6540d7f1794fcadeb849ffa4030141b857f5b
Author: Silas Brack <silasbrack@gmail.com>
Date: Sun, 28 Dec 2025 12:45:20 +0100
Fixes
Diffstat:
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/qml/views/MessageThreadView.qml b/qml/views/MessageThreadView.qml
@@ -81,6 +81,9 @@ Item {
model: messageListModel.model
+ // Track if we should auto-scroll (when at bottom or on initial load)
+ property bool shouldAutoScroll: true
+
// Detect when user scrolls to top (to load older messages)
onAtYBeginningChanged: {
if (atYBeginning && model.count > 0 && messageListModel.hasMore && !messageListModel.isLoadingMore) {
@@ -88,6 +91,22 @@ Item {
}
}
+ // Detect manual scrolling (disable auto-scroll if user scrolls up)
+ onContentYChanged: {
+ if (!messageList.atYEnd && !messageListModel.isLoadingMore) {
+ shouldAutoScroll = false
+ } else if (messageList.atYEnd) {
+ shouldAutoScroll = true
+ }
+ }
+
+ // Auto-scroll to bottom when new messages arrive
+ onCountChanged: {
+ if (shouldAutoScroll && count > 0) {
+ Qt.callLater(positionViewAtEnd)
+ }
+ }
+
delegate: MessageBubble {
width: messageList.width
messageData: model
@@ -95,13 +114,13 @@ Item {
// Auto-scroll to bottom on load
Component.onCompleted: {
- positionViewAtEnd()
+ Qt.callLater(positionViewAtEnd)
}
// Loading indicator at top (for older messages)
header: Item {
width: messageList.width
- height: messageListModel.isLoadingMore ? 60 : 0
+ implicitHeight: 60
visible: messageListModel.isLoadingMore
}
}
@@ -111,13 +130,13 @@ Item {
MessageInput {
Layout.fillWidth: true
enabled: !root.isSending && root.chatId >= 0
- onSendMessage: {
+ onSendMessage: (text) => {
if (text.trim().length > 0 && root.chatId >= 0) {
root.isSending = true
NetworkManager.postMessage(root.chatId, text)
}
}
- onAttachClicked: {
+ onAttachClicked: () => {
console.log("Attach clicked")
}
}