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:
@@ -16,6 +16,7 @@ Item {
|
|||||||
property alias inputFieldText: chatBar.inputFieldText
|
property alias inputFieldText: chatBar.inputFieldText
|
||||||
|
|
||||||
signal fancyEffectsReasonFound(string fancyEffect)
|
signal fancyEffectsReasonFound(string fancyEffect)
|
||||||
|
signal messageSent()
|
||||||
|
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||||
|
|
||||||
@@ -150,6 +151,7 @@ Item {
|
|||||||
onMessageSent: {
|
onMessageSent: {
|
||||||
closeAll()
|
closeAll()
|
||||||
checkForFancyEffectsReason()
|
checkForFancyEffectsReason()
|
||||||
|
root.messageSent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -567,8 +567,7 @@ Kirigami.ScrollablePage {
|
|||||||
if (currentRoom && currentRoom.hasUnreadMessages) {
|
if (currentRoom && currentRoom.hasUnreadMessages) {
|
||||||
goToEvent(currentRoom.readMarkerEventId)
|
goToEvent(currentRoom.readMarkerEventId)
|
||||||
} else {
|
} else {
|
||||||
currentRoom.markAllMessagesAsRead()
|
goToLastMessage();
|
||||||
messageListView.positionViewAtBeginning()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
icon.name: currentRoom && currentRoom.hasUnreadMessages ? "go-up" : "go-down"
|
icon.name: currentRoom && currentRoom.hasUnreadMessages ? "go-up" : "go-down"
|
||||||
@@ -654,6 +653,11 @@ Kirigami.ScrollablePage {
|
|||||||
footer: ChatBox {
|
footer: ChatBox {
|
||||||
id: chatBox
|
id: chatBox
|
||||||
visible: !invitation.visible && !(messageListView.count === 0 && !currentRoom.allHistoryLoaded)
|
visible: !invitation.visible && !(messageListView.count === 0 && !currentRoom.allHistoryLoaded)
|
||||||
|
onMessageSent: {
|
||||||
|
if (!messageListView.atYEnd) {
|
||||||
|
goToLastMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
background: FancyEffectsContainer {
|
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) {
|
function goToEvent(eventID) {
|
||||||
messageListView.positionViewAtIndex(eventToIndex(eventID), ListView.Contain)
|
messageListView.positionViewAtIndex(eventToIndex(eventID), ListView.Contain)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user