fix(chat): mark messages as read only if all messages have been viewed

fixes: #10150
This commit is contained in:
Patryk Osmaczko 2023-04-04 13:01:30 +02:00 committed by Jonathan Rainville
parent e950162bbc
commit 9419c9acaf
3 changed files with 16 additions and 5 deletions

View File

@ -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) =

View File

@ -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

View File

@ -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