diff --git a/src/app/modules/main/chat_section/chat_content/messages/module.nim b/src/app/modules/main/chat_section/chat_content/messages/module.nim index 402bc8c5811..4a4165882b6 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/module.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/module.nim @@ -678,6 +678,7 @@ method resendChatMessage*(self: Module, messageId: string): string = return self.controller.resendChatMessage(messageId) method resetNewMessagesMarker*(self: Module) = + self.view.setFirstUnseenMessageLoaded(false) self.controller.getAsyncFirstUnseenMessageId() method removeNewMessagesMarker*(self: Module) = diff --git a/ui/app/AppLayouts/Chat/stores/MessageStore.qml b/ui/app/AppLayouts/Chat/stores/MessageStore.qml index e743a7a656a..b5f796b5926 100644 --- a/ui/app/AppLayouts/Chat/stores/MessageStore.qml +++ b/ui/app/AppLayouts/Chat/stores/MessageStore.qml @@ -11,6 +11,8 @@ QtObject { readonly property bool loadingHistoryMessagesInProgress: root.chatSectionModule? root.chatSectionModule.loadingHistoryMessagesInProgress : false readonly property int newMessagesCount: messagesModel ? messagesModel.newMessagesCount : 0 readonly property bool messageSearchOngoing: messageModule ? messageModule.messageSearchOngoing : false + readonly property bool initialMessagesLoaded: messageModule ? messageModule.initialMessagesLoaded : false + readonly property bool firstUnseenMessageLoaded: messageModule ? messageModule.firstUnseenMessageLoaded : false readonly property bool amIChatAdmin: messageModule ? messageModule.amIChatAdmin : false readonly property bool isPinMessageAllowedForMembers: messageModule ? messageModule.isPinMessageAllowedForMembers : false diff --git a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml index 59849d4a89e..94e5fd676bd 100644 --- a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml @@ -59,7 +59,8 @@ Item { return } - if (chatDetails && chatDetails.active && chatDetails.hasUnreadMessages && !messageStore.messageSearchOngoing) { + if (chatDetails && chatDetails.active && chatDetails.hasUnreadMessages && + !messageStore.messageSearchOngoing && messageStore.firstUnseenMessageLoaded) { chatContentModule.markAllMessagesRead() } } @@ -85,14 +86,21 @@ Item { function onScrollToFirstUnreadMessage(messageIndex) { if (d.isMostRecentMessageInViewport) { - chatLogView.positionViewAtIndex(messageIndex, ListView.Center) - chatLogView.itemAtIndex(messageIndex).startMessageFoundAnimation() + onScrollToMessage(messageIndex) } } + } + + Connections { + target: root.messageStore function onMessageSearchOngoingChanged() { d.markAllMessagesReadIfMostRecentMessageIsInViewport() } + + function onFirstUnseenMessageLoadedChanged() { + d.markAllMessagesReadIfMostRecentMessageIsInViewport() + } } Connections { @@ -155,8 +163,8 @@ Item { Loader { id: loadingMessagesView - readonly property bool show: !messageStore.messageModule.firstUnseenMessageLoaded || - !messageStore.messageModule.initialMessagesLoaded + readonly property bool show: !messageStore.firstUnseenMessageLoaded || + !messageStore.initialMessagesLoaded active: show visible: show anchors.top: loadingMessagesIndicator.bottom