Add hack around atYEnd
This fixes the annoying "I just scrolled down to the bottom, how come
NeoChat doesn't think I did?"
From what I can tell this is also ListView bug (or something caused by
our style/Kirigami) that creates cases like contentY being -643.2 (for a
ListView of height 643) thus that's not "at Y's end". For our case
though, we don't care and can safely round it.
(cherry picked from commit 3c77711417)
This commit is contained in:
@@ -88,6 +88,9 @@ QQC2.ScrollView {
|
||||
ListView {
|
||||
id: messageListView
|
||||
|
||||
// HACK: Use this instead of atYEnd to handle cases like -643.2 at height of 643 not being counted as "at the beginning"
|
||||
readonly property bool closeToYEnd: -Math.round(contentY) >= height
|
||||
|
||||
/**
|
||||
* @brief Whether all unread messages in the timeline are visible.
|
||||
*/
|
||||
@@ -135,7 +138,7 @@ QQC2.ScrollView {
|
||||
Shortcut {
|
||||
sequences: [ StandardKey.Cancel ]
|
||||
onActivated: {
|
||||
if (!messageListView.atYEnd || !_private.room.partiallyReadStats.empty()) {
|
||||
if (!messageListView.closeToYEnd || !_private.room.partiallyReadStats.empty()) {
|
||||
messageListView.positionViewAtBeginning();
|
||||
} else {
|
||||
(root.Kirigami.PageStack.pageStack as Kirigami.PageRow).get(0).forceActiveFocus();
|
||||
@@ -184,12 +187,12 @@ QQC2.ScrollView {
|
||||
}
|
||||
}
|
||||
|
||||
onAtYEndChanged: if (atYEnd && _private.hasScrolledUpBefore) {
|
||||
onCloseToYEndChanged: if (closeToYEnd && _private.hasScrolledUpBefore) {
|
||||
if (QQC2.ApplicationWindow.window && (QQC2.ApplicationWindow.window.visibility !== QQC2.ApplicationWindow.Hidden)) {
|
||||
_private.room.markAllMessagesAsRead();
|
||||
}
|
||||
_private.hasScrolledUpBefore = false;
|
||||
} else if (!atYEnd) {
|
||||
} else if (!closeToYEnd) {
|
||||
_private.hasScrolledUpBefore = true;
|
||||
}
|
||||
|
||||
@@ -245,7 +248,7 @@ QQC2.ScrollView {
|
||||
padding: Kirigami.Units.largeSpacing
|
||||
|
||||
z: 2
|
||||
visible: !messageListView.atYEnd
|
||||
visible: !messageListView.closeToYEnd
|
||||
|
||||
text: i18nc("@action:button", "Jump to latest message")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user