Improve the unread marker behaviour
The fixes include: - improving the timer to make it more reliable - making sure a read marker is added when changin rooms, this is needed when the messages have already been loaded. - increase the default timer to 10s to avoid the read marker disappearing and being re-added when a message arrive in quick succession. BUG: 465300
This commit is contained in:
@@ -253,6 +253,12 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
lastReadEventId.clear();
|
||||
}
|
||||
endResetModel();
|
||||
|
||||
// After reset put a read marker in if required.
|
||||
// This is needed when changing back to a room that has already loaded messages.
|
||||
if (room) {
|
||||
moveReadMarker(m_currentRoom->lastFullyReadEventId());
|
||||
}
|
||||
}
|
||||
|
||||
int MessageEventModel::refreshEvent(const QString &eventId)
|
||||
|
||||
@@ -102,6 +102,7 @@ QQC2.ScrollView {
|
||||
interval: 1000
|
||||
onTriggered: {
|
||||
root.roomChanging = false
|
||||
markReadIfVisibleTimer.reset()
|
||||
}
|
||||
}
|
||||
onAtYEndChanged: if (!root.roomChanging) {
|
||||
@@ -273,19 +274,19 @@ QQC2.ScrollView {
|
||||
target: root.timelineModel
|
||||
|
||||
function onRowsInserted() {
|
||||
markReadIfVisibleTimer.restart()
|
||||
markReadIfVisibleTimer.reset()
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: markReadIfVisibleTimer
|
||||
interval: 1000
|
||||
onTriggered: {
|
||||
if (loading || !root.currentRoom.readMarkerLoaded || !applicationWindow().active) {
|
||||
restart()
|
||||
} else {
|
||||
messageListView.markReadIfVisible()
|
||||
}
|
||||
running: messageListView.allUnreadVisible() && applicationWindow().active && (root.currentRoom.timelineSize > 0 || root.currentRoom.allHistoryLoaded)
|
||||
interval: 10000
|
||||
onTriggered: root.currentRoom.markAllMessagesAsRead()
|
||||
|
||||
function reset() {
|
||||
restart()
|
||||
running = Qt.binding(function() { return messageListView.allUnreadVisible() && applicationWindow().active && (root.currentRoom.timelineSize > 0 || root.currentRoom.allHistoryLoaded) })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,12 +365,12 @@ QQC2.ScrollView {
|
||||
return index;
|
||||
}
|
||||
|
||||
// Mark all messages as read if all unread messages are visible to the user
|
||||
function markReadIfVisible() {
|
||||
function allUnreadVisible() {
|
||||
let readMarkerRow = eventToIndex(root.currentRoom.readMarkerEventId)
|
||||
if (readMarkerRow >= 0 && readMarkerRow < firstVisibleIndex() && messageListView.atYEnd) {
|
||||
root.currentRoom.markAllMessagesAsRead()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function setHoverActionsToDelegate(delegate) {
|
||||
|
||||
Reference in New Issue
Block a user