diff --git a/smsapp/qml/ConversationDisplay.qml b/smsapp/qml/ConversationDisplay.qml index f7afbfcdf..a061151e7 100644 --- a/smsapp/qml/ConversationDisplay.qml +++ b/smsapp/qml/ConversationDisplay.qml @@ -148,15 +148,26 @@ Kirigami.ScrollablePage } } - onMovementEnded: { + /// As the user scrolls, load more messages when they get to the top. + /// This used to use the onMovementEnded signal, but at some point + /// that signal stopped being emitted reliably when scrolling with + /// the mouse. onContentYChanged is fine for our use, just a bit noisy. + onContentYChanged: { if (!isInitalized) { return } - // Unset the highlightRangeMode if it was set previously - highlightRangeMode = ListView.ApplyRange - // If we have scrolled to the last message currently in the view, request some more - if (atYBeginning) { + // If we have scrolled near to the top, request more messages + // This threshold of visibleArea.yPosition has been chosen experimentally, but + // should generally be OK because it is defined as a ratio of the content to the visible + // area. As more messages get loaded into our view, this constant will start to be + // less-sane, meaning we will request messages earlier as the user scrolls back in time. + // This is probably a good thing, because it means that scrolling back further and further + // quickly, will be more likely to be smooth. + // Combined with `atYBeginning`, the view scrolls smoothly for me, long past the point where + // the rest of the app is stable, and past the point where Android can fetch messages fast + // enough. + if (visibleArea.yPosition < 0.075 || atYBeginning) { // "Lock" the view to the message currently at the beginning of the view // This prevents the view from snapping to the top of the messages we are about to request currentIndex = 0 // Index 0 is the beginning of the view