fix(@desktop/chat): Show badge and message in activity center for reply elements
Fix #5523
This commit is contained in:
parent
0ee0c8ddd4
commit
2e5f1c9c4d
|
@ -116,4 +116,10 @@ proc getChannelGroups*(self: Controller): seq[ChannelGroupDto] =
|
|||
return self.chatService.getChannelGroups()
|
||||
|
||||
proc getOneToOneChatNameAndImage*(self: Controller, chatId: string): tuple[name: string, image: string] =
|
||||
return self.chatService.getOneToOneChatNameAndImage(chatId)
|
||||
return self.chatService.getOneToOneChatNameAndImage(chatId)
|
||||
|
||||
proc getMessageById*(self: Controller, chatId, messageId: string): MessageDto =
|
||||
let (message, _, err) = self.messageService.getDetailsForMessage(chatId, messageId)
|
||||
if(err.len > 0):
|
||||
return MessageDto()
|
||||
return message
|
|
@ -13,6 +13,7 @@ type Item* = ref object
|
|||
dismissed: bool
|
||||
accepted: bool
|
||||
messageItem: MessageItem
|
||||
repliedMessageItem: MessageItem
|
||||
|
||||
proc initItem*(
|
||||
id: string,
|
||||
|
@ -25,7 +26,8 @@ proc initItem*(
|
|||
read: bool,
|
||||
dismissed: bool,
|
||||
accepted: bool,
|
||||
messageItem: MessageItem
|
||||
messageItem: MessageItem,
|
||||
repliedMessageItem: MessageItem
|
||||
): Item =
|
||||
result = Item()
|
||||
result.id = id
|
||||
|
@ -39,6 +41,7 @@ proc initItem*(
|
|||
result.dismissed = dismissed
|
||||
result.accepted = accepted
|
||||
result.messageItem = messageItem
|
||||
result.repliedMessageItem = repliedMessageItem
|
||||
|
||||
proc `$`*(self: Item): string =
|
||||
result = fmt"""StickerItem(
|
||||
|
@ -53,6 +56,7 @@ proc `$`*(self: Item): string =
|
|||
dismissed: {$self.dismissed},
|
||||
accepted: {$self.accepted},
|
||||
# messageItem: {$self.messageItem},
|
||||
# repliedMessageItem: {$self.repliedMessageItem},
|
||||
]"""
|
||||
|
||||
proc id*(self: Item): string =
|
||||
|
@ -90,3 +94,6 @@ proc accepted*(self: Item): bool =
|
|||
|
||||
proc messageItem*(self: Item): MessageItem =
|
||||
return self.messageItem
|
||||
|
||||
proc repliedMessageItem*(self: Item): MessageItem =
|
||||
return self.repliedMessageItem
|
|
@ -14,6 +14,7 @@ type
|
|||
Dismissed
|
||||
Accepted
|
||||
Author
|
||||
RepliedMessage
|
||||
|
||||
QtObject:
|
||||
type
|
||||
|
@ -80,6 +81,7 @@ QtObject:
|
|||
of NotifRoles.Read: result = newQVariant(acitivityNotificationItem.read.bool)
|
||||
of NotifRoles.Dismissed: result = newQVariant(acitivityNotificationItem.dismissed.bool)
|
||||
of NotifRoles.Accepted: result = newQVariant(acitivityNotificationItem.accepted.bool)
|
||||
of NotifRoles.RepliedMessage: result = newQVariant(acitivityNotificationItem.repliedMessageItem)
|
||||
|
||||
proc getNotificationData(self: Model, index: int, data: string): string {.slot.} =
|
||||
if index < 0 or index >= self.activityCenterNotifications.len: return ("")
|
||||
|
@ -110,7 +112,8 @@ QtObject:
|
|||
NotifRoles.Timestamp.int: "timestamp",
|
||||
NotifRoles.Read.int: "read",
|
||||
NotifRoles.Dismissed.int: "dismissed",
|
||||
NotifRoles.Accepted.int: "accepted"
|
||||
NotifRoles.Accepted.int: "accepted",
|
||||
NotifRoles.RepliedMessage.int: "repliedMessage"
|
||||
}.toTable
|
||||
|
||||
proc reduceUnreadCount(self: Model, numberNotifs: int) =
|
||||
|
|
|
@ -68,6 +68,33 @@ method hasMoreToShow*(self: Module): bool =
|
|||
method unreadActivityCenterNotificationsCount*(self: Module): int =
|
||||
self.controller.unreadActivityCenterNotificationsCount()
|
||||
|
||||
proc createMessageItemFromDto(self: Module, message: MessageDto, chatDetails: ChatDto): MessageItem =
|
||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||
return msg_item_qobj.newMessageItem(msg_item.initItem(
|
||||
message.id,
|
||||
chatDetails.communityId, # we don't received community id via `activityCenterNotifications` api call
|
||||
message.responseTo,
|
||||
message.`from`,
|
||||
contactDetails.displayName,
|
||||
contactDetails.details.localNickname,
|
||||
contactDetails.icon,
|
||||
contactDetails.isCurrentUser,
|
||||
contactDetails.details.added,
|
||||
message.outgoingStatus,
|
||||
self.controller.getRenderedText(message.parsedText),
|
||||
message.image,
|
||||
message.containsContactMentions(),
|
||||
message.seen,
|
||||
message.timestamp,
|
||||
ContentType(message.contentType),
|
||||
message.messageType,
|
||||
self.controller.decodeContentHash(message.sticker.hash),
|
||||
message.sticker.pack,
|
||||
message.links,
|
||||
newTransactionParametersItem("","","","","","",-1,""),
|
||||
message.mentionedUsersPks
|
||||
))
|
||||
|
||||
method convertToItems*(
|
||||
self: Module,
|
||||
activityCenterNotifications: seq[ActivityCenterNotificationDto]
|
||||
|
@ -75,6 +102,7 @@ method convertToItems*(
|
|||
result = activityCenterNotifications.map(
|
||||
proc(n: ActivityCenterNotificationDto): notification_item.Item =
|
||||
var messageItem = msg_item_qobj.newMessageItem(nil)
|
||||
var repliedMessageItem = msg_item_qobj.newMessageItem(nil)
|
||||
|
||||
let chatDetails = self.controller.getChatDetails(n.chatId)
|
||||
# default section id is `Chat` section
|
||||
|
@ -85,31 +113,11 @@ method convertToItems*(
|
|||
|
||||
if (n.message.id != ""):
|
||||
# If there is a message in the Notification, transfer it to a MessageItem (QObject)
|
||||
let contactDetails = self.controller.getContactDetails(n.message.`from`)
|
||||
messageItem = msg_item_qobj.newMessageItem(msg_item.initItem(
|
||||
n.message.id,
|
||||
chatDetails.communityId, # we don't received community id via `activityCenterNotifications` api call
|
||||
n.message.responseTo,
|
||||
n.message.`from`,
|
||||
contactDetails.displayName,
|
||||
contactDetails.details.localNickname,
|
||||
contactDetails.icon,
|
||||
contactDetails.isCurrentUser,
|
||||
contactDetails.details.added,
|
||||
n.message.outgoingStatus,
|
||||
self.controller.getRenderedText(n.message.parsedText),
|
||||
n.message.image,
|
||||
n.message.containsContactMentions(),
|
||||
n.message.seen,
|
||||
n.message.timestamp,
|
||||
ContentType(n.message.contentType),
|
||||
n.message.messageType,
|
||||
self.controller.decodeContentHash(n.message.sticker.hash),
|
||||
n.message.sticker.pack,
|
||||
n.message.links,
|
||||
newTransactionParametersItem("","","","","","",-1,""),
|
||||
n.message.mentionedUsersPks
|
||||
))
|
||||
messageItem = self.createMessageItemFromDto(n.message, chatDetails)
|
||||
|
||||
if (n.notificationType == ActivityCenterNotificationType.Reply and n.message.responseTo != ""):
|
||||
let repliedMessage = self.controller.getMessageById(n.chatId, n.message.responseTo)
|
||||
repliedMessageItem = self.createMessageItemFromDto(repliedMessage, chatDetails)
|
||||
|
||||
return notification_item.initItem(
|
||||
n.id,
|
||||
|
@ -122,7 +130,8 @@ method convertToItems*(
|
|||
n.read,
|
||||
n.dismissed,
|
||||
n.accepted,
|
||||
messageItem
|
||||
messageItem,
|
||||
repliedMessageItem
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ import StatusQ.Core.Utils 0.1 as StatusQUtils
|
|||
Item {
|
||||
id: replyComponent
|
||||
|
||||
property int replyMessageIndex: wrapper.replyMessageIndex
|
||||
property int repliedMessageId: wrapper.repliedMessageId
|
||||
property string repliedMessageContent: wrapper.repliedMessageContent
|
||||
|
||||
onReplyMessageIndexChanged: {
|
||||
wrapper.visible = replyMessageIndex > -1
|
||||
onRepliedMessageIdChanged: {
|
||||
wrapper.visible = (repliedMessageId.length > 0)
|
||||
}
|
||||
|
||||
SVGImage {
|
||||
|
|
|
@ -20,7 +20,7 @@ Rectangle {
|
|||
property string communityName: ""
|
||||
property string communityColor: ""
|
||||
property string communityThumbnailImage: ""
|
||||
property int replyMessageIndex: -1
|
||||
property string repliedMessageId: ""
|
||||
property string repliedMessageContent: ""
|
||||
property int notificationType
|
||||
property string profileImage: ""
|
||||
|
@ -56,7 +56,7 @@ Rectangle {
|
|||
ActivityCenter.ReplyComponent {
|
||||
width: childrenRect.width
|
||||
height: parent.height
|
||||
replyMessageIndex: wrapper.replyMessageIndex
|
||||
repliedMessageId: wrapper.repliedMessageId
|
||||
repliedMessageContent: wrapper.repliedMessageContent
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ Item {
|
|||
|
||||
function reevaluateItemBadge() {
|
||||
let details = root.store.getBadgeDetails(model.sectionId, model.chatId)
|
||||
badge.isCommunity = details.sType == "community"
|
||||
badge.isCommunity = (details.sType === "community")
|
||||
badge.name = details.cName
|
||||
badge.channelName = details.cName
|
||||
badge.communityName = details.sName
|
||||
|
@ -185,6 +185,8 @@ Item {
|
|||
visible: model.notificationType !== Constants.activityCenterNotificationTypeOneToOne
|
||||
notificationType: model.notificationType
|
||||
profileImage: realChatType === Constants.chatType.oneToOne ? Global.getProfileImage(chatId) || "" : ""
|
||||
repliedMessageContent: model.repliedMessage.messageText
|
||||
repliedMessageId: model.message.responseToMessageWithId
|
||||
|
||||
onCommunityNameClicked: {
|
||||
root.store.activityCenterModuleInst.switchTo(model.sectionId, "", "")
|
||||
|
|
Loading…
Reference in New Issue