From 87d1fefae29f6e35cf5cf671b6d13157da3b3a5c Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 31 May 2021 17:21:03 +0200 Subject: [PATCH] Don't mark message as read when the current window is not visible Fix #378 --- imports/NeoChat/Page/RoomPage.qml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index 347e5872a..279121aad 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -260,7 +260,9 @@ Kirigami.ScrollablePage { } onAtYEndChanged: if (atYEnd && hasScrolledUpBefore) { - currentRoom.markAllMessagesAsRead(); + if (QQC2.ApplicationWindow.window.visibility !== QQC2.ApplicationWindow.Hidden) { + currentRoom.markAllMessagesAsRead(); + } hasScrolledUpBefore = false; } else if (!atYEnd) { hasScrolledUpBefore = true; @@ -573,7 +575,9 @@ Kirigami.ScrollablePage { Timer { id: makeMeDisapearTimer interval: Kirigami.Units.humanMoment * 2 - onTriggered: currentRoom.markAllMessagesAsRead(); + onTriggered: if (QQC2.ApplicationWindow.window.visibility !== QQC2.ApplicationWindow.Hidden) { + currentRoom.markAllMessagesAsRead(); + } } ListView.onPooled: makeMeDisapearTimer.stop() @@ -600,7 +604,9 @@ Kirigami.ScrollablePage { if (view.atYEnd) { // easy case just mark everything as read - currentRoom.markAllMessagesAsRead(); + if (QQC2.ApplicationWindow.window.visibility !== QQC2.ApplicationWindow.Hidden) { + currentRoom.markAllMessagesAsRead(); + } return; } @@ -616,11 +622,7 @@ Kirigami.ScrollablePage { DelegateChoice { roleValue: "other" - delegate: Rectangle { - height: 10 - width: ListView.view.width - color: "red" - } + delegate: Item {} } }