2018-10-02 02:07:47 +00:00
|
|
|
import QtQuick 2.9
|
|
|
|
|
|
|
|
RoomPanelForm {
|
|
|
|
roomHeader.onClicked: roomDrawer.open()
|
|
|
|
roomHeader.image: spectralController.safeImage(currentRoom ? currentRoom.avatar : null)
|
|
|
|
roomHeader.topic: currentRoom ? (currentRoom.topic).replace(/(\r\n\t|\n|\r\t)/gm,"") : ""
|
|
|
|
|
|
|
|
sortedMessageEventModel.onModelReset: {
|
|
|
|
if (currentRoom)
|
|
|
|
{
|
|
|
|
var lastScrollPosition = sortedMessageEventModel.mapFromSource(currentRoom.savedTopVisibleIndex())
|
2018-10-13 07:31:31 +00:00
|
|
|
console.log("Scrolling to position", lastScrollPosition)
|
|
|
|
messageListView.currentIndex = lastScrollPosition
|
2018-10-02 02:07:47 +00:00
|
|
|
if (messageListView.contentY < messageListView.originY + 10 || currentRoom.timelineSize === 0)
|
|
|
|
currentRoom.getPreviousContent(100)
|
|
|
|
}
|
|
|
|
console.log("Model timeline reset")
|
|
|
|
}
|
|
|
|
|
|
|
|
messageListView {
|
2018-10-02 02:21:39 +00:00
|
|
|
property int largestVisibleIndex: messageListView.count > 0 ? messageListView.indexAt(messageListView.contentX, messageListView.contentY + messageListView.height - 1) : -1
|
2018-10-02 02:07:47 +00:00
|
|
|
|
|
|
|
onContentYChanged: {
|
2018-10-15 00:24:08 +00:00
|
|
|
if(currentRoom && messageListView.contentY - 5000 < messageListView.originY)
|
2018-10-02 02:07:47 +00:00
|
|
|
currentRoom.getPreviousContent(50);
|
|
|
|
}
|
|
|
|
|
|
|
|
onMovementEnded: {
|
|
|
|
currentRoom.saveViewport(sortedMessageEventModel.mapToSource(messageListView.indexAt(messageListView.contentX, messageListView.contentY)), sortedMessageEventModel.mapToSource(largestVisibleIndex))
|
|
|
|
var newReadMarker = sortedMessageEventModel.get(largestVisibleIndex).eventId
|
|
|
|
if (newReadMarker) currentRoom.readMarkerEventId = newReadMarker
|
|
|
|
}
|
|
|
|
|
|
|
|
displaced: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
property: "y"; duration: 200
|
|
|
|
easing.type: Easing.OutQuad
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-08 12:51:00 +00:00
|
|
|
goTopFab.onClicked: messageListView.positionViewAtBeginning()
|
2018-10-02 02:07:47 +00:00
|
|
|
}
|