diff --git a/src/app/modules/main/activity_center/module.nim b/src/app/modules/main/activity_center/module.nim index 62d1213df0..b74652339a 100644 --- a/src/app/modules/main/activity_center/module.nim +++ b/src/app/modules/main/activity_center/module.nim @@ -74,6 +74,7 @@ method convertToItems*[T]( let contactDetails = self.controller.getContactDetails(n.message.`from`) messageItem = message_item_qobject.newMessageItem(initItem( n.message.id, + n.message.communityId, n.message.responseTo, n.message.`from`, contactDetails.displayName, 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 fcd191c199..ab3e43ba83 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 @@ -73,6 +73,7 @@ proc createFetchMoreMessagesItem(self: Module): Item = let isIdenticon = false result = initItem( FETCH_MORE_MESSAGES_MESSAGE_ID, + communityId = "", responseToMessageWithId = "", senderId = chatDto.id, senderDisplayName = "", @@ -104,6 +105,7 @@ proc createChatIdentifierItem(self: Module): Item = result = initItem( CHAT_IDENTIFIER_MESSAGE_ID, + communityId = "", responseToMessageWithId = "", senderId = chatDto.id, senderDisplayName = chatName, @@ -165,6 +167,7 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se isCurrentUser = self.currentUserWalletContainsAddress(m.transactionParameters.fromAddress) var item = initItem( m.id, + m.communityId, m.responseTo, m.`from`, sender.displayName, @@ -246,6 +249,7 @@ method messageAdded*(self: Module, message: MessageDto) = self.view.model().removeItem(message.replace) var item = initItem( message.id, + message.communityId, message.responseTo, message.`from`, sender.displayName, diff --git a/src/app/modules/main/chat_section/chat_content/module.nim b/src/app/modules/main/chat_section/chat_content/module.nim index 587c74af83..07f2352fb4 100644 --- a/src/app/modules/main/chat_section/chat_content/module.nim +++ b/src/app/modules/main/chat_section/chat_content/module.nim @@ -157,6 +157,7 @@ proc buildPinnedMessageItem(self: Module, messageId: string, actionInitiatedBy: isCurrentUser = self.currentUserWalletContainsAddress(m.transactionParameters.fromAddress) item = pinned_msg_item.initItem( m.id, + m.communityId, m.responseTo, m.`from`, contactDetails.displayName, diff --git a/src/app/modules/main/communities/controller.nim b/src/app/modules/main/communities/controller.nim index 7d464e9040..61e80c0617 100644 --- a/src/app/modules/main/communities/controller.nim +++ b/src/app/modules/main/communities/controller.nim @@ -40,6 +40,10 @@ method init*(self: Controller) = let args = CommunityArgs(e) self.delegate.communityAdded(args.community) + self.events.on(SIGNAL_COMMUNITY_ADDED) do(e:Args): + let args = CommunityArgs(e) + self.delegate.communityAdded(args.community) + self.events.on(SIGNAL_COMMUNITY_IMPORTED) do(e:Args): let args = CommunityArgs(e) if(args.error.len > 0): diff --git a/src/app/modules/shared_models/message_item.nim b/src/app/modules/shared_models/message_item.nim index 06cbb7ff2b..12fdf6a1ef 100644 --- a/src/app/modules/shared_models/message_item.nim +++ b/src/app/modules/shared_models/message_item.nim @@ -7,6 +7,7 @@ import message_reaction_model, message_reaction_item, message_transaction_parame type Item* = ref object id: string + communityId: string responseToMessageWithId: string senderId: string senderDisplayName: string @@ -36,6 +37,7 @@ type proc initItem*( id, + communityId, responseToMessageWithId, senderId, senderDisplayName, @@ -58,6 +60,7 @@ proc initItem*( ): Item = result = Item() result.id = id + result.communityId = communityId result.responseToMessageWithId = responseToMessageWithId result.senderId = senderId result.senderDisplayName = senderDisplayName @@ -85,6 +88,7 @@ proc initItem*( proc `$`*(self: Item): string = result = fmt"""Item( id: {$self.id}, + communityId: {$self.communityId}, responseToMessageWithId: {self.responseToMessageWithId}, senderId: {self.senderId}, senderDisplayName: {$self.senderDisplayName}, @@ -110,6 +114,9 @@ proc `$`*(self: Item): string = proc id*(self: Item): string {.inline.} = self.id +proc communityId*(self: Item): string {.inline.} = + self.communityId + proc responseToMessageWithId*(self: Item): string {.inline.} = self.responseToMessageWithId @@ -219,6 +226,7 @@ proc transactionParameters*(self: Item): TransactionParametersItem {.inline.} = proc toJsonNode*(self: Item): JsonNode = result = %* { "id": self.id, + "communityId": self.communityId, "responseToMessageWithId": self.responseToMessageWithId, "senderId": self.senderId, "senderDisplayName": self.senderDisplayName, diff --git a/src/app/modules/shared_models/message_model.nim b/src/app/modules/shared_models/message_model.nim index fa45e6ec81..736162f207 100644 --- a/src/app/modules/shared_models/message_model.nim +++ b/src/app/modules/shared_models/message_model.nim @@ -5,6 +5,7 @@ import message_item, message_reaction_item, message_transaction_parameters_item type ModelRole {.pure.} = enum Id = UserRole + 1 + CommunityId ResponseToMessageWithId SenderId SenderDisplayName @@ -75,6 +76,7 @@ QtObject: method roleNames(self: Model): Table[int, string] = { ModelRole.Id.int:"id", + ModelRole.CommunityId.int:"communityId", ModelRole.ResponseToMessageWithId.int:"responseToMessageWithId", ModelRole.SenderId.int:"senderId", ModelRole.SenderDisplayName.int:"senderDisplayName", @@ -116,6 +118,8 @@ QtObject: case enumRole: of ModelRole.Id: result = newQVariant(item.id) + of ModelRole.CommunityId: + result = newQVariant(item.communityId) of ModelRole.ResponseToMessageWithId: result = newQVariant(item.responseToMessageWithId) of ModelRole.SenderId: diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index 40fe2d799e..ed09a73b68 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -66,6 +66,7 @@ const SIGNAL_COMMUNITY_JOINED* = "communityJoined" const SIGNAL_COMMUNITY_MY_REQUEST_ADDED* = "communityMyRequestAdded" const SIGNAL_COMMUNITY_LEFT* = "communityLeft" const SIGNAL_COMMUNITY_CREATED* = "communityCreated" +const SIGNAL_COMMUNITY_ADDED* = "communityAdded" const SIGNAL_COMMUNITY_IMPORTED* = "communityImported" const SIGNAL_COMMUNITY_DATA_IMPORTED* = "communityDataImported" # This one is when just loading the data with requestCommunityInfo const SIGNAL_COMMUNITY_EDITED* = "communityEdited" @@ -183,6 +184,12 @@ QtObject: proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto]) = var community = communities[0] + + if(not self.allCommunities.hasKey(community.id)): + self.events.emit(SIGNAL_COMMUNITY_ADDED, CommunityArgs(community: community)) + # add or update community + self.allCommunities[community.id] = community + if(not self.joinedCommunities.hasKey(community.id)): return diff --git a/src/app_service/service/message/dto/message.nim b/src/app_service/service/message/dto/message.nim index 6d23ff64fb..11f5c5ab9f 100644 --- a/src/app_service/service/message/dto/message.nim +++ b/src/app_service/service/message/dto/message.nim @@ -48,6 +48,7 @@ type TransactionParameters* = object type MessageDto* = object id*: string + communityId*: string whisperTimestamp*: int64 `from`*: string alias*: string @@ -120,6 +121,7 @@ proc toTransactionParameters*(jsonObj: JsonNode): TransactionParameters = proc toMessageDto*(jsonObj: JsonNode): MessageDto = result = MessageDto() discard jsonObj.getProp("id", result.id) + discard jsonObj.getProp("communityId", result.communityId) discard jsonObj.getProp("whisperTimestamp", result.whisperTimestamp) discard jsonObj.getProp("from", result.from) discard jsonObj.getProp("alias", result.alias) diff --git a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml index e1587609ca..36e044c2ef 100644 --- a/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatMessagesView.qml @@ -249,6 +249,7 @@ Item { messageContextMenu: messageContextMenuInst messageId: model.id + communityId: model.communityId responseToMessageWithId: model.responseToMessageWithId senderId: model.senderId senderDisplayName: model.senderDisplayName diff --git a/ui/imports/shared/views/chat/CompactMessageView.qml b/ui/imports/shared/views/chat/CompactMessageView.qml index 2c22d12a7b..c45d9a8f12 100644 --- a/ui/imports/shared/views/chat/CompactMessageView.qml +++ b/ui/imports/shared/views/chat/CompactMessageView.qml @@ -35,6 +35,7 @@ Item { property bool amISender: false property bool isHovered: false property bool isInPinnedPopup: false + property string communityId property bool showMoreButton: { if(!root.messageStore) return false @@ -643,9 +644,8 @@ Item { sourceComponent: Component { id: invitationBubble InvitationBubbleView { - // Not Refactored Yet -// store: rootStore - communityId: root.container.communityId + store: root.store + communityId: root.communityId } } } diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 0fbed47540..78e6ed9a73 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -28,6 +28,7 @@ Column { property bool isChatBlocked: false property string messageId: "" + property string communityId: "" property string responseToMessageWithId: "" property string senderId: "" property string senderDisplayName: "" @@ -365,6 +366,7 @@ Column { contentType: root.messageContentType isChatBlocked: root.isChatBlocked + communityId: root.communityId stickersLoaded: root.stickersLoaded sticker: root.sticker stickerPack: root.stickerPack