feat: scroll to bottom on new user message
when the user sends a new message, and if the user is at an older position in the timeline, then neochat should automatically scroll to the latest message and mark all the messages as read
This commit is contained in:
@@ -567,8 +567,7 @@ Kirigami.ScrollablePage {
|
||||
if (currentRoom && currentRoom.hasUnreadMessages) {
|
||||
goToEvent(currentRoom.readMarkerEventId)
|
||||
} else {
|
||||
currentRoom.markAllMessagesAsRead()
|
||||
messageListView.positionViewAtBeginning()
|
||||
goToLastMessage();
|
||||
}
|
||||
}
|
||||
icon.name: currentRoom && currentRoom.hasUnreadMessages ? "go-up" : "go-down"
|
||||
@@ -654,6 +653,11 @@ Kirigami.ScrollablePage {
|
||||
footer: ChatBox {
|
||||
id: chatBox
|
||||
visible: !invitation.visible && !(messageListView.count === 0 && !currentRoom.allHistoryLoaded)
|
||||
onMessageSent: {
|
||||
if (!messageListView.atYEnd) {
|
||||
goToLastMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
background: FancyEffectsContainer {
|
||||
@@ -690,6 +694,12 @@ Kirigami.ScrollablePage {
|
||||
}
|
||||
}
|
||||
|
||||
function goToLastMessage() {
|
||||
currentRoom.markAllMessagesAsRead()
|
||||
// scroll to the very end, i.e to messageListView.YEnd
|
||||
messageListView.positionViewAtIndex(0, ListView.End)
|
||||
}
|
||||
|
||||
function goToEvent(eventID) {
|
||||
messageListView.positionViewAtIndex(eventToIndex(eventID), ListView.Contain)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user