fix(invitation): fix community invite not showing in 1-1 chats

Fixes #4851
This commit is contained in:
Jonathan Rainville 2022-02-24 10:04:59 -05:00 committed by Iuri Matias
parent 52fb195b39
commit 3985272037
11 changed files with 37 additions and 3 deletions

View File

@ -74,6 +74,7 @@ method convertToItems*[T](
let contactDetails = self.controller.getContactDetails(n.message.`from`) let contactDetails = self.controller.getContactDetails(n.message.`from`)
messageItem = message_item_qobject.newMessageItem(initItem( messageItem = message_item_qobject.newMessageItem(initItem(
n.message.id, n.message.id,
n.message.communityId,
n.message.responseTo, n.message.responseTo,
n.message.`from`, n.message.`from`,
contactDetails.displayName, contactDetails.displayName,

View File

@ -73,6 +73,7 @@ proc createFetchMoreMessagesItem(self: Module): Item =
let isIdenticon = false let isIdenticon = false
result = initItem( result = initItem(
FETCH_MORE_MESSAGES_MESSAGE_ID, FETCH_MORE_MESSAGES_MESSAGE_ID,
communityId = "",
responseToMessageWithId = "", responseToMessageWithId = "",
senderId = chatDto.id, senderId = chatDto.id,
senderDisplayName = "", senderDisplayName = "",
@ -104,6 +105,7 @@ proc createChatIdentifierItem(self: Module): Item =
result = initItem( result = initItem(
CHAT_IDENTIFIER_MESSAGE_ID, CHAT_IDENTIFIER_MESSAGE_ID,
communityId = "",
responseToMessageWithId = "", responseToMessageWithId = "",
senderId = chatDto.id, senderId = chatDto.id,
senderDisplayName = chatName, senderDisplayName = chatName,
@ -165,6 +167,7 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se
isCurrentUser = self.currentUserWalletContainsAddress(m.transactionParameters.fromAddress) isCurrentUser = self.currentUserWalletContainsAddress(m.transactionParameters.fromAddress)
var item = initItem( var item = initItem(
m.id, m.id,
m.communityId,
m.responseTo, m.responseTo,
m.`from`, m.`from`,
sender.displayName, sender.displayName,
@ -246,6 +249,7 @@ method messageAdded*(self: Module, message: MessageDto) =
self.view.model().removeItem(message.replace) self.view.model().removeItem(message.replace)
var item = initItem( var item = initItem(
message.id, message.id,
message.communityId,
message.responseTo, message.responseTo,
message.`from`, message.`from`,
sender.displayName, sender.displayName,

View File

@ -157,6 +157,7 @@ proc buildPinnedMessageItem(self: Module, messageId: string, actionInitiatedBy:
isCurrentUser = self.currentUserWalletContainsAddress(m.transactionParameters.fromAddress) isCurrentUser = self.currentUserWalletContainsAddress(m.transactionParameters.fromAddress)
item = pinned_msg_item.initItem( item = pinned_msg_item.initItem(
m.id, m.id,
m.communityId,
m.responseTo, m.responseTo,
m.`from`, m.`from`,
contactDetails.displayName, contactDetails.displayName,

View File

@ -40,6 +40,10 @@ method init*(self: Controller) =
let args = CommunityArgs(e) let args = CommunityArgs(e)
self.delegate.communityAdded(args.community) 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): self.events.on(SIGNAL_COMMUNITY_IMPORTED) do(e:Args):
let args = CommunityArgs(e) let args = CommunityArgs(e)
if(args.error.len > 0): if(args.error.len > 0):

View File

@ -7,6 +7,7 @@ import message_reaction_model, message_reaction_item, message_transaction_parame
type type
Item* = ref object Item* = ref object
id: string id: string
communityId: string
responseToMessageWithId: string responseToMessageWithId: string
senderId: string senderId: string
senderDisplayName: string senderDisplayName: string
@ -36,6 +37,7 @@ type
proc initItem*( proc initItem*(
id, id,
communityId,
responseToMessageWithId, responseToMessageWithId,
senderId, senderId,
senderDisplayName, senderDisplayName,
@ -58,6 +60,7 @@ proc initItem*(
): Item = ): Item =
result = Item() result = Item()
result.id = id result.id = id
result.communityId = communityId
result.responseToMessageWithId = responseToMessageWithId result.responseToMessageWithId = responseToMessageWithId
result.senderId = senderId result.senderId = senderId
result.senderDisplayName = senderDisplayName result.senderDisplayName = senderDisplayName
@ -85,6 +88,7 @@ proc initItem*(
proc `$`*(self: Item): string = proc `$`*(self: Item): string =
result = fmt"""Item( result = fmt"""Item(
id: {$self.id}, id: {$self.id},
communityId: {$self.communityId},
responseToMessageWithId: {self.responseToMessageWithId}, responseToMessageWithId: {self.responseToMessageWithId},
senderId: {self.senderId}, senderId: {self.senderId},
senderDisplayName: {$self.senderDisplayName}, senderDisplayName: {$self.senderDisplayName},
@ -110,6 +114,9 @@ proc `$`*(self: Item): string =
proc id*(self: Item): string {.inline.} = proc id*(self: Item): string {.inline.} =
self.id self.id
proc communityId*(self: Item): string {.inline.} =
self.communityId
proc responseToMessageWithId*(self: Item): string {.inline.} = proc responseToMessageWithId*(self: Item): string {.inline.} =
self.responseToMessageWithId self.responseToMessageWithId
@ -219,6 +226,7 @@ proc transactionParameters*(self: Item): TransactionParametersItem {.inline.} =
proc toJsonNode*(self: Item): JsonNode = proc toJsonNode*(self: Item): JsonNode =
result = %* { result = %* {
"id": self.id, "id": self.id,
"communityId": self.communityId,
"responseToMessageWithId": self.responseToMessageWithId, "responseToMessageWithId": self.responseToMessageWithId,
"senderId": self.senderId, "senderId": self.senderId,
"senderDisplayName": self.senderDisplayName, "senderDisplayName": self.senderDisplayName,

View File

@ -5,6 +5,7 @@ import message_item, message_reaction_item, message_transaction_parameters_item
type type
ModelRole {.pure.} = enum ModelRole {.pure.} = enum
Id = UserRole + 1 Id = UserRole + 1
CommunityId
ResponseToMessageWithId ResponseToMessageWithId
SenderId SenderId
SenderDisplayName SenderDisplayName
@ -75,6 +76,7 @@ QtObject:
method roleNames(self: Model): Table[int, string] = method roleNames(self: Model): Table[int, string] =
{ {
ModelRole.Id.int:"id", ModelRole.Id.int:"id",
ModelRole.CommunityId.int:"communityId",
ModelRole.ResponseToMessageWithId.int:"responseToMessageWithId", ModelRole.ResponseToMessageWithId.int:"responseToMessageWithId",
ModelRole.SenderId.int:"senderId", ModelRole.SenderId.int:"senderId",
ModelRole.SenderDisplayName.int:"senderDisplayName", ModelRole.SenderDisplayName.int:"senderDisplayName",
@ -116,6 +118,8 @@ QtObject:
case enumRole: case enumRole:
of ModelRole.Id: of ModelRole.Id:
result = newQVariant(item.id) result = newQVariant(item.id)
of ModelRole.CommunityId:
result = newQVariant(item.communityId)
of ModelRole.ResponseToMessageWithId: of ModelRole.ResponseToMessageWithId:
result = newQVariant(item.responseToMessageWithId) result = newQVariant(item.responseToMessageWithId)
of ModelRole.SenderId: of ModelRole.SenderId:

View File

@ -66,6 +66,7 @@ const SIGNAL_COMMUNITY_JOINED* = "communityJoined"
const SIGNAL_COMMUNITY_MY_REQUEST_ADDED* = "communityMyRequestAdded" const SIGNAL_COMMUNITY_MY_REQUEST_ADDED* = "communityMyRequestAdded"
const SIGNAL_COMMUNITY_LEFT* = "communityLeft" const SIGNAL_COMMUNITY_LEFT* = "communityLeft"
const SIGNAL_COMMUNITY_CREATED* = "communityCreated" const SIGNAL_COMMUNITY_CREATED* = "communityCreated"
const SIGNAL_COMMUNITY_ADDED* = "communityAdded"
const SIGNAL_COMMUNITY_IMPORTED* = "communityImported" const SIGNAL_COMMUNITY_IMPORTED* = "communityImported"
const SIGNAL_COMMUNITY_DATA_IMPORTED* = "communityDataImported" # This one is when just loading the data with requestCommunityInfo const SIGNAL_COMMUNITY_DATA_IMPORTED* = "communityDataImported" # This one is when just loading the data with requestCommunityInfo
const SIGNAL_COMMUNITY_EDITED* = "communityEdited" const SIGNAL_COMMUNITY_EDITED* = "communityEdited"
@ -183,6 +184,12 @@ QtObject:
proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto]) = proc handleCommunityUpdates(self: Service, communities: seq[CommunityDto], updatedChats: seq[ChatDto]) =
var community = communities[0] 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)): if(not self.joinedCommunities.hasKey(community.id)):
return return

View File

@ -48,6 +48,7 @@ type TransactionParameters* = object
type MessageDto* = object type MessageDto* = object
id*: string id*: string
communityId*: string
whisperTimestamp*: int64 whisperTimestamp*: int64
`from`*: string `from`*: string
alias*: string alias*: string
@ -120,6 +121,7 @@ proc toTransactionParameters*(jsonObj: JsonNode): TransactionParameters =
proc toMessageDto*(jsonObj: JsonNode): MessageDto = proc toMessageDto*(jsonObj: JsonNode): MessageDto =
result = MessageDto() result = MessageDto()
discard jsonObj.getProp("id", result.id) discard jsonObj.getProp("id", result.id)
discard jsonObj.getProp("communityId", result.communityId)
discard jsonObj.getProp("whisperTimestamp", result.whisperTimestamp) discard jsonObj.getProp("whisperTimestamp", result.whisperTimestamp)
discard jsonObj.getProp("from", result.from) discard jsonObj.getProp("from", result.from)
discard jsonObj.getProp("alias", result.alias) discard jsonObj.getProp("alias", result.alias)

View File

@ -249,6 +249,7 @@ Item {
messageContextMenu: messageContextMenuInst messageContextMenu: messageContextMenuInst
messageId: model.id messageId: model.id
communityId: model.communityId
responseToMessageWithId: model.responseToMessageWithId responseToMessageWithId: model.responseToMessageWithId
senderId: model.senderId senderId: model.senderId
senderDisplayName: model.senderDisplayName senderDisplayName: model.senderDisplayName

View File

@ -35,6 +35,7 @@ Item {
property bool amISender: false property bool amISender: false
property bool isHovered: false property bool isHovered: false
property bool isInPinnedPopup: false property bool isInPinnedPopup: false
property string communityId
property bool showMoreButton: { property bool showMoreButton: {
if(!root.messageStore) if(!root.messageStore)
return false return false
@ -643,9 +644,8 @@ Item {
sourceComponent: Component { sourceComponent: Component {
id: invitationBubble id: invitationBubble
InvitationBubbleView { InvitationBubbleView {
// Not Refactored Yet store: root.store
// store: rootStore communityId: root.communityId
communityId: root.container.communityId
} }
} }
} }

View File

@ -28,6 +28,7 @@ Column {
property bool isChatBlocked: false property bool isChatBlocked: false
property string messageId: "" property string messageId: ""
property string communityId: ""
property string responseToMessageWithId: "" property string responseToMessageWithId: ""
property string senderId: "" property string senderId: ""
property string senderDisplayName: "" property string senderDisplayName: ""
@ -365,6 +366,7 @@ Column {
contentType: root.messageContentType contentType: root.messageContentType
isChatBlocked: root.isChatBlocked isChatBlocked: root.isChatBlocked
communityId: root.communityId
stickersLoaded: root.stickersLoaded stickersLoaded: root.stickersLoaded
sticker: root.sticker sticker: root.sticker
stickerPack: root.stickerPack stickerPack: root.stickerPack