summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2024-04-05 02:52:45 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2024-04-05 02:52:45 +0200
commita5f99b50eb427e2f100625374343323860481770 (patch)
tree7d0536242a668a1d2dc77eb657180526e9b6b3f6
parentTry harder to make transparency for windows icon work (diff)
downloadnheko-a5f99b50eb427e2f100625374343323860481770.tar.xz
Hopefully fix the jump when replying after scrolling
-rw-r--r--resources/qml/MessageView.qml18
-rw-r--r--resources/qml/TimelineSectionHeader.qml4
2 files changed, 16 insertions, 6 deletions
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index 09447ab3..5ad414f7 100644
--- a/resources/qml/MessageView.qml
+++ b/resources/qml/MessageView.qml
@@ -28,6 +28,16 @@ Item {
 
         target: MainWindow
     }
+
+    Connections {
+        function onScrollToIndex(index) {
+            chat.positionViewAtIndex(index, ListView.Center);
+            chat.updateLastScroll();
+        }
+
+        target: room
+    }
+
     ScrollBar {
         id: scrollbar
 
@@ -59,8 +69,11 @@ Item {
         property int lastScrollPos: 0
 
         // Fixup the scroll position when the height changes. Without this, the view is kept around the center of the currently visible content, while we usually want to stick to the bottom.
-        onMovementEnded: lastScrollPos = (contentY+height)
-        onModelChanged: lastScrollPos = (contentY+height)
+        function updateLastScroll() {
+            lastScrollPos = (contentY+height);
+        }
+        onMovementEnded: updateLastScroll()
+        onModelChanged: updateLastScroll()
         onHeightChanged: contentY = (lastScrollPos-height)
 
         Component {
@@ -651,6 +664,7 @@ Item {
         onClicked: function () {
             chat.positionViewAtBeginning();
             TimelineManager.focusMessageInput();
+            chat.updateLastScroll();
         }
 
         anchors {
diff --git a/resources/qml/TimelineSectionHeader.qml b/resources/qml/TimelineSectionHeader.qml
index 17971b75..4ae4f286 100644
--- a/resources/qml/TimelineSectionHeader.qml
+++ b/resources/qml/TimelineSectionHeader.qml
@@ -73,10 +73,6 @@ Column {
             function onRoomAvatarUrlChanged() {
                 messageUserAvatar.url = room.avatarUrl(userId).replace("mxc://", "image://MxcImage/");
             }
-            function onScrollToIndex(index) {
-                chat.positionViewAtIndex(index, ListView.Center);
-            }
-
             target: room
         }