Skip to content

Commit

Permalink
Tweaked the logic of moving reactions into the view (#543)
Browse files Browse the repository at this point in the history
There's no need to reposition list items if reactions bar are already
fully visible.
  • Loading branch information
monich authored Dec 3, 2023
1 parent 47ee859 commit b2363af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 9 additions & 5 deletions qml/components/MessageListViewItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions qml/pages/ChatPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit b2363af

Please sign in to comment.