diff --git a/src/qml/Component/TimelineView.qml b/src/qml/Component/TimelineView.qml index cc87d05aa..1a85e02c4 100644 --- a/src/qml/Component/TimelineView.qml +++ b/src/qml/Component/TimelineView.qml @@ -16,9 +16,19 @@ import org.kde.neochat 1.0 QQC2.ScrollView { id: root required property NeoChatRoom currentRoom - readonly property bool isLoaded: root.width * root.height > 10 + onCurrentRoomChanged: { + roomChanging = true; + applicationWindow().hoverLinkIndicator.text = ""; + messageListView.positionViewAtBeginning(); + hasScrolledUpBefore = false; + roomChanging = true; + } + property bool roomChanging: false readonly property bool atYEnd: messageListView.atYEnd + /// Used to determine if scrolling to the bottom should mark the message as unread + property bool hasScrolledUpBefore: false; + signal focusChatBox() ListView { @@ -38,7 +48,7 @@ QQC2.ScrollView { interactive: Kirigami.Settings.isMobile bottomMargin: Kirigami.Units.largeSpacing + Math.round(Kirigami.Theme.defaultFont.pointSize * 2) - model: !isLoaded ? undefined : collapseStateProxyModel + model: collapseStateProxyModel MessageEventModel { id: messageEventModel @@ -70,13 +80,15 @@ QQC2.ScrollView { messageEventModel.fetchMore(messageEventModel.index(0, 0)); } - onAtYEndChanged: if (atYEnd && hasScrolledUpBefore) { - if (QQC2.ApplicationWindow.window && (QQC2.ApplicationWindow.window.visibility !== QQC2.ApplicationWindow.Hidden)) { - root.currentRoom.markAllMessagesAsRead(); + onAtYEndChanged: if (!root.roomChanging) { + if (atYEnd && root.hasScrolledUpBefore) { + if (QQC2.ApplicationWindow.window && (QQC2.ApplicationWindow.window.visibility !== QQC2.ApplicationWindow.Hidden)) { + root.currentRoom.markAllMessagesAsRead(); + } + root.hasScrolledUpBefore = false; + } else if (!atYEnd) { + root.hasScrolledUpBefore = true; } - hasScrolledUpBefore = false; - } else if (!atYEnd) { - hasScrolledUpBefore = true; } // Not rendered because the sections are part of the TimelineContainer.qml, this is only so that items have the section property available for use by sectionBanner. diff --git a/src/qml/Page/RoomPage.qml b/src/qml/Page/RoomPage.qml index 4fafa3ba7..bb4430a6a 100644 --- a/src/qml/Page/RoomPage.qml +++ b/src/qml/Page/RoomPage.qml @@ -19,8 +19,6 @@ Kirigami.Page { /// Not readonly because of the separate window view. property NeoChatRoom currentRoom: RoomManager.currentRoom property bool loading: !root.currentRoom || (root.currentRoom.timelineSize === 0 && !root.currentRoom.allHistoryLoaded) - /// Used to determine if scrolling to the bottom should mark the message as unread - property bool hasScrolledUpBefore: false; /// Disable cancel shortcut. Used by the separate window since it provides its own cancel implementation. property bool disableCancelShortcut: false @@ -32,12 +30,6 @@ Kirigami.Page { KeyNavigation.left: pageStack.get(0) onCurrentRoomChanged: { - if (!timelineViewLoader.item) { - return - } - applicationWindow().hoverLinkIndicator.text = ""; - timelineViewLoader.item.positionViewAtBeginning(); - hasScrolledUpBefore = false; if (!Kirigami.Settings.isMobile && chatBoxLoader.item) { chatBoxLoader.item.forceActiveFocus(); }