Tweaked the logic of moving reactions into the view (#543)

There's no need to reposition list items if reactions bar are already
fully visible.
This commit is contained in:
Slava Monich 2023-12-03 13:53:32 +02:00 committed by GitHub
parent 47ee85915d
commit b2363af36f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View file

@ -325,11 +325,15 @@ ListItem {
onTriggered: {
Debug.log("Show item completely timer triggered, requested index: " + requestedIndex + ", current index: " + index)
if (requestedIndex === index) {
chatView.highlightMoveDuration = -1;
chatView.highlightResizeDuration = -1;
chatView.scrollToIndex(requestedIndex);
chatView.highlightMoveDuration = 0;
chatView.highlightResizeDuration = 0;
var p = chatView.contentItem.mapFromItem(reactionsColumn, 0, 0)
if (chatView.contentY > p.y || p.y + reactionsColumn.height > chatView.contentY + chatView.height) {
Debug.log("Moving reactions for item at", requestedIndex, "info the view")
chatView.highlightMoveDuration = -1
chatView.highlightResizeDuration = -1
chatView.scrollToIndex(requestedIndex, height <= chatView.height ? ListView.Contain : ListView.End)
chatView.highlightMoveDuration = 0
chatView.highlightResizeDuration = 0
}
}
}
}

View file

@ -1241,10 +1241,9 @@ Page {
manuallyScrolledToBottom = chatView.atYEnd
}
function scrollToIndex(index) {
function scrollToIndex(index, mode) {
if(index > 0 && index < chatView.count) {
positionViewAtIndex(index, ListView.Contain)
// currentIndex = index;
positionViewAtIndex(index, (mode === undefined) ? ListView.Contain : mode)
if(index === chatView.count - 1) {
manuallyScrolledToBottom = true;
}