fix(chat): fix chat highlighted because it was never marked as read

Fixes #11365
This commit is contained in:
Jonathan Rainville 2023-10-02 14:44:32 -04:00
parent a227db592d
commit 9dc5527627
4 changed files with 20 additions and 5 deletions

View File

@ -16,6 +16,7 @@ QtObject:
emoji: string
hasUnreadMessages: bool
notificationsCount: int
highlight: bool
muted: bool
position: int
isUntrustworthy: bool
@ -32,7 +33,7 @@ QtObject:
proc setChatDetails*(self: ChatDetails, id: string, `type`: int, belongsToCommunity,
isUsersListAvailable: bool, name, icon: string, color, description,
emoji: string, hasUnreadMessages: bool, notificationsCount: int, muted: bool, position: int,
emoji: string, hasUnreadMessages: bool, notificationsCount: int, highlight, muted: bool, position: int,
isUntrustworthy: bool, isContact: bool = false, blocked: bool = false) =
self.id = id
self.`type` = `type`
@ -45,6 +46,7 @@ QtObject:
self.description = description
self.hasUnreadMessages = hasUnreadMessages
self.notificationsCount = notificationsCount
self.highlight = highlight
self.muted = muted
self.position = position
self.isUntrustworthy = isUntrustworthy
@ -149,6 +151,17 @@ QtObject:
self.notificationsCount = value
self.notificationCountChanged()
proc highlightChanged(self: ChatDetails) {.signal.}
proc getHighlight*(self: ChatDetails): bool {.slot.} =
return self.highlight
QtProperty[bool] highlight:
read = getHighlight
notify = highlightChanged
proc setHighlight*(self: ChatDetails, value: bool) = # this is not a slot
self.highlight = value
self.highlightChanged()
proc mutedChanged(self: ChatDetails) {.signal.}
proc getMuted(self: ChatDetails): bool {.slot.} =
return self.muted

View File

@ -91,7 +91,7 @@ method load*(self: Module, chatItem: chat_item.Item) =
self.view.load(chatItem.id, chatItem.`type`, self.controller.belongsToCommunity(),
self.controller.isUsersListAvailable(), chatName, chatImage,
chatItem.color, chatItem.description, chatItem.emoji, chatItem.hasUnreadMessages, chatItem.notificationsCount,
chatItem.muted, chatItem.position, isUntrustworthy = trustStatus == TrustStatus.Untrustworthy,
chatItem.highlight, chatItem.muted, chatItem.position, isUntrustworthy = trustStatus == TrustStatus.Untrustworthy,
isContact, chatItem.blocked)
self.inputAreaModule.load()

View File

@ -39,10 +39,10 @@ QtObject:
proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool,
name, icon: string, color, description, emoji: string, hasUnreadMessages: bool,
notificationsCount: int, muted: bool, position: int, isUntrustworthy: bool,
notificationsCount: int, highlight, muted: bool, position: int, isUntrustworthy: bool,
isContact: bool, blocked: bool) =
self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name,
icon, color, description, emoji, hasUnreadMessages, notificationsCount, muted, position,
icon, color, description, emoji, hasUnreadMessages, notificationsCount, highlight, muted, position,
isUntrustworthy, isContact, blocked)
self.delegate.viewDidLoad()
self.chatDetailsChanged()
@ -123,6 +123,8 @@ QtObject:
proc updateChatDetailsNotifications*(self: View, hasUnreadMessages: bool, notificationCount: int) =
self.chatDetails.setHasUnreadMessages(hasUnreadMessages)
self.chatDetails.setNotificationCount(notificationCount)
if self.chatDetails.getHighlight and not hasUnreadMessages:
self.chatDetails.setHighlight(false)
proc getChatDetails(self: View): QVariant {.slot.} =
return self.chatDetailsVariant

View File

@ -62,7 +62,7 @@ Item {
return
}
if (chatDetails && chatDetails.active && chatDetails.hasUnreadMessages && !messageStore.loading) {
if (chatDetails && chatDetails.active && (chatDetails.hasUnreadMessages || chatDetails.highlight) && !messageStore.loading) {
chatContentModule.markAllMessagesRead()
}
}