Allow the condition for when messages are automatically marked as read to be configurable.

Title this adds a number of options for when messages should be automatically marked as read for the user to choose from.

![image](/uploads/cef95f8c6c77bfdcabb7a8a309bc1fd2/image.png){width=480 height=262}
This commit is contained in:
James Graham
2025-07-04 14:36:36 +01:00
parent d5d291396d
commit 3d9d211d25
11 changed files with 160 additions and 42 deletions

View File

@@ -35,6 +35,11 @@ QQC2.ScrollView {
*/
property bool fileDropEnabled: true
/**
* @brief The TimelineMarkReadCondition to use for when messages should be marked as read automatically.
*/
required property int markReadCondition
/**
* @brief Shift the view to the given event ID.
*/
@@ -54,7 +59,6 @@ QQC2.ScrollView {
* All messages will be marked as read.
*/
function goToLastMessage() {
_private.room.markAllMessagesAsRead();
messageListView.positionViewAtBeginning();
}
@@ -154,8 +158,8 @@ QQC2.ScrollView {
}
function onReadMarkerAdded() {
if (messageListView.allUnreadVisible()) {
_private.room.markAllMessagesAsRead();
if (root.markReadCondition == LibNeoChat.TimelineMarkReadCondition.EntryVisible && messageListView.allUnreadVisible()) {
root.room.markAllMessagesAsRead();
}
}
@@ -163,6 +167,20 @@ QQC2.ScrollView {
messageListView.positionViewAtBeginning();
_private.room.markAllMessagesAsRead();
}
function onRoomAboutToChange(oldRoom, newRoom) {
if (root.markReadCondition == LibNeoChat.TimelineMarkReadCondition.Exit ||
(root.markReadCondition == LibNeoChat.TimelineMarkReadCondition.ExitVisible && messageListView.allUnreadVisible())
) {
oldRoom.markAllMessagesAsRead();
}
}
function onRoomChanged(oldRoom, newRoom) {
if (root.markReadCondition == LibNeoChat.TimelineMarkReadCondition.Entry) {
newRoom.markAllMessagesAsRead();
}
}
}
onAtYEndChanged: if (atYEnd && _private.hasScrolledUpBefore) {