diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index 94e5825b4..de5bbf3a1 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -23,13 +23,18 @@ Kirigami.ScrollablePage { /// It's not readonly because of the seperate window view. property var currentRoom: RoomManager.currentRoom + /// Used to determine if scrolling to the bottom should mark the message as unread + property bool hasScrolledUpBefore: false; title: currentRoom.displayName signal switchRoomUp() signal switchRoomDown() - onCurrentRoomChanged: ChatBoxHelper.clearEditReply() + onCurrentRoomChanged: { + hasScrolledUpBefore = false; + ChatBoxHelper.clearEditReply() + } ActionsHandler { id: actionsHandler @@ -254,6 +259,13 @@ Kirigami.ScrollablePage { messageEventModel.fetchMore(messageEventModel.index(0, 0)); } + onAtYEndChanged: if (atYEnd && hasScrolledUpBefore) { + currentRoom.markAllMessagesAsRead(); + hasScrolledUpBefore = false; + } else if (!atYEnd) { + hasScrolledUpBefore = true; + } + QQC2.Popup { anchors.centerIn: parent