From 482d61ee4748ac8cd5457be4da22020ce4045ed4 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sat, 30 Mar 2024 19:32:19 +0000 Subject: [PATCH] Fix marking messages as read when the window is thin Make sure that messages are not marked as read when going back to the roomlist after entering a room when neochat is thin and only showing a single page Fixes #642 --- src/qml/RoomPage.qml | 1 + src/qml/TimelineView.qml | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qml/RoomPage.qml b/src/qml/RoomPage.qml index 09382355a..3f5843719 100644 --- a/src/qml/RoomPage.qml +++ b/src/qml/RoomPage.qml @@ -120,6 +120,7 @@ Kirigami.Page { sourceComponent: TimelineView { id: timelineView currentRoom: root.currentRoom + page: root timelineModel: root.timelineModel messageFilterModel: root.messageFilterModel actionsHandler: root.actionsHandler diff --git a/src/qml/TimelineView.qml b/src/qml/TimelineView.qml index c7117db95..af6897dcd 100644 --- a/src/qml/TimelineView.qml +++ b/src/qml/TimelineView.qml @@ -27,6 +27,8 @@ QQC2.ScrollView { } property bool roomChanging: false + required property Item page + /** * @brief The TimelineModel to use. * @@ -299,14 +301,14 @@ QQC2.ScrollView { Timer { id: markReadIfVisibleTimer - running: messageListView.allUnreadVisible() && applicationWindow().active && (root.currentRoom.timelineSize > 0 || root.currentRoom.allHistoryLoaded) + running: messageListView.allUnreadVisible() && applicationWindow().active && (root.currentRoom.timelineSize > 0 || root.currentRoom.allHistoryLoaded) && applicationWindow().pageStack.visibleItems.includes(root.page) 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); + return messageListView.allUnreadVisible() && applicationWindow().active && (root.currentRoom.timelineSize > 0 || root.currentRoom.allHistoryLoaded) && applicationWindow().pageStack.visibleItems.includes(root.page); }); } }