mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-21 20:09:37 +00:00
fix(@desktop/activity-center): mentions and replies in the activity centre does not display community icon
Fixes #5302
This commit is contained in:
parent
8d4aa7dd56
commit
9c9d633065
@ -110,4 +110,10 @@ proc switchTo*(self: Controller, sectionId, chatId, messageId: string) =
|
||||
self.events.emit(SIGNAL_MAKE_SECTION_CHAT_ACTIVE, data)
|
||||
|
||||
proc getChatDetails*(self: Controller, chatId: string): ChatDto =
|
||||
return self.chatService.getChatById(chatId)
|
||||
return self.chatService.getChatById(chatId)
|
||||
|
||||
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)
|
@ -68,3 +68,6 @@ method dismissActivityCenterNotifications*(self: AccessInterface, notificationId
|
||||
|
||||
method switchTo*(self: AccessInterface, sectionId, chatId, messageId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getDetails*(self: AccessInterface, sectionId: string, chatId: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
@ -1,4 +1,4 @@
|
||||
import NimQml, Tables, stint, sugar, sequtils
|
||||
import NimQml, Tables, json, stint, sugar, sequtils
|
||||
|
||||
import ./io_interface, ./view, ./controller
|
||||
import ../io_interface as delegate_interface
|
||||
@ -203,3 +203,31 @@ method dismissActivityCenterNotifications*(self: Module, notificationIds: seq[st
|
||||
|
||||
method switchTo*(self: Module, sectionId, chatId, messageId: string) =
|
||||
self.controller.switchTo(sectionId, chatId, messageId)
|
||||
|
||||
method getDetails*(self: Module, sectionId: string, chatId: string): string =
|
||||
let groups = self.controller.getChannelGroups()
|
||||
var jsonObject = newJObject()
|
||||
|
||||
for g in groups:
|
||||
if(g.id != sectionId):
|
||||
continue
|
||||
|
||||
jsonObject["sType"] = %* g.channelGroupType
|
||||
jsonObject["sName"] = %* g.name
|
||||
jsonObject["sImage"] = %* g.images.thumbnail
|
||||
jsonObject["sColor"] = %* g.color
|
||||
|
||||
for c in g.chats:
|
||||
if(c.id != chatId):
|
||||
continue
|
||||
|
||||
var chatName = c.name
|
||||
var chatImage = c.icon
|
||||
if(c.chatType == ChatType.OneToOne):
|
||||
(chatName, chatImage) = self.controller.getOneToOneChatNameAndImage(c.id)
|
||||
|
||||
jsonObject["cName"] = %* chatName
|
||||
jsonObject["cImage"] = %* chatImage
|
||||
jsonObject["cColor"] = %* c.color
|
||||
jsonObject["cEmoji"] = %* c.emoji
|
||||
return $jsonObject
|
@ -44,7 +44,6 @@ QtObject:
|
||||
|
||||
proc pushActivityCenterNotifications*(self:View, activityCenterNotifications: seq[Item]) =
|
||||
self.model.addActivityNotificationItemsToList(activityCenterNotifications)
|
||||
self.activityNotificationsChanged()
|
||||
self.hasMoreToShowChanged()
|
||||
|
||||
let count = self.delegate.unreadActivityCenterNotificationsCount()
|
||||
@ -125,7 +124,9 @@ QtObject:
|
||||
# if communityId != "":
|
||||
# self.communities.joinedCommunityList.decrementMentions(communityId, activityCenterNotification.chatId)
|
||||
self.model.addActivityNotificationItemToList(activityCenterNotification)
|
||||
self.activityNotificationsChanged()
|
||||
|
||||
proc switchTo*(self: View, sectionId: string, chatId: string, messageId: string) {.slot.} =
|
||||
self.delegate.switchTo(sectionId, chatId, messageId)
|
||||
|
||||
proc getDetails*(self: View, sectionId: string, chatId: string): string {.slot.} =
|
||||
return self.delegate.getDetails(sectionId, chatId)
|
@ -17,7 +17,6 @@ Item {
|
||||
property int realChatType: -1
|
||||
property string name: "channelName"
|
||||
property color textColor
|
||||
property string chatId: ""
|
||||
property string profileImage: ""
|
||||
|
||||
SVGImage {
|
||||
|
@ -26,7 +26,6 @@ Item {
|
||||
|
||||
SVGImage {
|
||||
id: communityIcon
|
||||
visible: !hideSecondIcon
|
||||
width: 16
|
||||
height: 16
|
||||
source: Style.svg("communities")
|
||||
|
@ -1,5 +1,7 @@
|
||||
import QtQuick 2.13
|
||||
|
||||
import StatusQ.Core.Theme 0.1
|
||||
|
||||
import utils 1.0
|
||||
import shared.controls 1.0
|
||||
import shared 1.0
|
||||
@ -11,10 +13,9 @@ import "../controls/activityCenter" as ActivityCenter
|
||||
Rectangle {
|
||||
id: wrapper
|
||||
|
||||
property bool isCommunity: false
|
||||
property string name: "channelName"
|
||||
property string chatId: ""
|
||||
property int realChatType: -1
|
||||
property string communityId
|
||||
property string channelName: ""
|
||||
property string communityName: ""
|
||||
property string communityColor: ""
|
||||
@ -24,7 +25,7 @@ Rectangle {
|
||||
property int notificationType
|
||||
property string profileImage: ""
|
||||
|
||||
property color textColor: Style.current.textColor
|
||||
property color textColor: Theme.palette.baseColor1
|
||||
|
||||
signal communityNameClicked()
|
||||
signal channelNameClicked()
|
||||
@ -43,9 +44,9 @@ Rectangle {
|
||||
anchors.leftMargin: 4
|
||||
sourceComponent: {
|
||||
switch (wrapper.notificationType) {
|
||||
case Constants.activityCenterNotificationTypeMention: return wrapper.communityId ? communityBadgeComponent : channelBadgeComponent
|
||||
case Constants.activityCenterNotificationTypeMention: return wrapper.isCommunity? communityBadgeComponent : channelBadgeComponent
|
||||
case Constants.activityCenterNotificationTypeReply: return replyComponent
|
||||
default: return wrapper.communityId ? communityBadgeComponent : channelBadgeComponent
|
||||
default: return wrapper.isCommunity? communityBadgeComponent : channelBadgeComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,8 +74,8 @@ Rectangle {
|
||||
channelName: wrapper.channelName
|
||||
name: wrapper.name
|
||||
|
||||
onCommunityNameClicked: communityNameClicked()
|
||||
onChannelNameClicked: channelNameClicked()
|
||||
onCommunityNameClicked: wrapper.communityNameClicked()
|
||||
onChannelNameClicked: wrapper.channelNameClicked()
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +88,6 @@ Rectangle {
|
||||
realChatType: wrapper.realChatType
|
||||
textColor: wrapper.textColor
|
||||
name: wrapper.name
|
||||
chatId: wrapper.chatId
|
||||
profileImage: wrapper.profileImage
|
||||
}
|
||||
}
|
||||
|
@ -207,9 +207,19 @@ Popup {
|
||||
id: messageNotificationComponent
|
||||
|
||||
ActivityCenterMessageComponentView {
|
||||
id: activityCenterMessageView
|
||||
store: activityCenter.store
|
||||
chatSectionModule: activityCenter.chatSectionModule
|
||||
messageContextMenu: activityCenter.messageContextMenu
|
||||
|
||||
Connections {
|
||||
target: activityCenter
|
||||
onOpened: activityCenterMessageView.reevaluateItemBadge()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
activityCenterMessageView.reevaluateItemBadge()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,6 +163,26 @@ QtObject {
|
||||
// Not Refactored Yet
|
||||
// property var activeCommunity: chatsModelInst.communities.activeCommunity
|
||||
|
||||
function getBadgeDetails(sectionId, chatId) {
|
||||
try {
|
||||
const jsonObj = root.activityCenterModuleInst.getDetails(sectionId, chatId)
|
||||
let obj = JSON.parse(jsonObj)
|
||||
return obj
|
||||
}
|
||||
catch (e) {
|
||||
return {
|
||||
sType: "",
|
||||
sName: "",
|
||||
sImage: "",
|
||||
sColor: "",
|
||||
cName: "",
|
||||
cImage: "",
|
||||
cColor: "",
|
||||
cEmoji: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sendSticker(channelId, hash, replyTo, pack) {
|
||||
stickersModuleInst.send(channelId, hash, replyTo, pack)
|
||||
}
|
||||
|
@ -41,6 +41,16 @@ Item {
|
||||
Global.openProfilePopup(model.author)
|
||||
}
|
||||
|
||||
function reevaluateItemBadge() {
|
||||
let details = root.store.getBadgeDetails(model.sectionId, model.chatId)
|
||||
badge.isCommunity = details.sType == "community"
|
||||
badge.name = details.cName
|
||||
badge.channelName = details.cName
|
||||
badge.communityName = details.sName
|
||||
badge.communityColor = details.sColor
|
||||
badge.communityThumbnailImage = details.sImage
|
||||
}
|
||||
|
||||
Component {
|
||||
id: markReadBtnComponent
|
||||
StatusFlatRoundButton {
|
||||
@ -123,12 +133,8 @@ Item {
|
||||
amISender: model.message.amISender
|
||||
messageImage: model.message.messageImage
|
||||
messageTimestamp: model.timestamp
|
||||
linkUrls: model.links
|
||||
messageOutgoingStatus: model.message.outgoingStatus
|
||||
messageContentType: model.message.contentType
|
||||
pinnedMessage: model.message.pinned
|
||||
messagePinnedBy: model.message.pinnedBy
|
||||
reactionsModel: model.message.reactions
|
||||
activityCenterMessage: true
|
||||
read: model.read
|
||||
onImageClicked: Global.openImagePopup(image, root.messageContextMenu)
|
||||
@ -177,53 +183,17 @@ Item {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 61 // TODO find a way to align with the text of the message
|
||||
visible: model.notificationType !== Constants.activityCenterNotificationTypeOneToOne
|
||||
name: model.name
|
||||
chatId: model.chatId
|
||||
notificationType: model.notificationType
|
||||
// communityId: model.message.communityId
|
||||
// Not Refactored Yet
|
||||
// replyMessageIndex: root.store.chatsModelInst.messageView.getMessageIndex(model.chatId, model.responseTo)
|
||||
// Not Refactored Yet
|
||||
// repliedMessageContent: replyMessageIndex > -1 ? root.store.chatsModelInst.messageView.getMessageData(chatId, replyMessageIndex, "message") : ""
|
||||
// realChatType: {
|
||||
// Not Refactored Yet
|
||||
// var chatType = root.store.chatsModelInst.channelView.chats.getChannelType(model.chatId)
|
||||
// if (chatType === Constants.chatType.communityChat) {
|
||||
// // TODO add a check for private community chats once it is created
|
||||
// return Constants.chatType.publicChat
|
||||
// }
|
||||
// return chatType
|
||||
// }
|
||||
profileImage: realChatType === Constants.chatType.oneToOne ? Global.getProfileImage(chatId) || "" : ""
|
||||
// Not Refactored Yet
|
||||
// channelName: root.store.chatsModelInst.getChannelNameById(badge.chatId)
|
||||
// Not Refactored Yet
|
||||
// communityName: root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "name") : ""
|
||||
// Not Refactored Yet
|
||||
// communityThumbnailImage: root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "thumbnailImage") : ""
|
||||
// Not Refactored Yet
|
||||
// communityColor: !model.image && root.communityIndex > -1 ? root.store.chatsModelInst.communities.joinedCommunities.rowData(root.communityIndex, "communityColor"): ""
|
||||
|
||||
onCommunityNameClicked: {
|
||||
// Not Refactored Yet
|
||||
// root.store.chatsModelInst.communities.setActiveCommunity(badge.communityId)
|
||||
root.store.activityCenterModuleInst.switchTo(model.sectionId, "", "")
|
||||
activityCenter.close()
|
||||
}
|
||||
onChannelNameClicked: {
|
||||
// Not Refactored Yet
|
||||
// root.store.chatsModelInst.communities.setActiveCommunity(badge.communityId)
|
||||
// root.store.chatsModelInst.setActiveChannel(badge.chatId)
|
||||
root.store.activityCenterModuleInst.switchTo(model.sectionId, model.chatId, "")
|
||||
activityCenter.close()
|
||||
}
|
||||
|
||||
// Not Refactored Yet
|
||||
// Connections {
|
||||
// enabled: badge.realChatType === Constants.chatType.oneToOne
|
||||
// target: root.store.allContacts
|
||||
// onContactChanged: {
|
||||
// if (pubkey === badge.chatId) {
|
||||
// badge.profileImage = Global.getProfileImage(badge.chatId)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ Item {
|
||||
+ (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0)
|
||||
|
||||
Connections {
|
||||
target: root.messageStore.messageModule
|
||||
target: root.messageStore.messageModule? root.messageStore.messageModule : null
|
||||
enabled: responseTo !== ""
|
||||
onRefreshAMessageUserRespondedTo: {
|
||||
if(msgId === messageId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user