fix: Fix behaviour issues with CRs and mutual update messages (#11178)
Close #11121
This commit is contained in:
parent
42f2546e4a
commit
1a7532d92c
|
@ -109,9 +109,7 @@ proc blockContact*(self: Controller, publicKey: string) =
|
|||
self.contactsService.blockContact(publicKey)
|
||||
|
||||
proc removeContact*(self: Controller, publicKey: string) =
|
||||
let response = self.contactsService.removeContact(publicKey)
|
||||
# TODO: segfault if using SIGNAL_CHAT_REQUEST_UPDATE_AFTER_SEND
|
||||
discard self.chatService.processMessageUpdateAfterSend(response)
|
||||
self.contactsService.removeContact(publicKey)
|
||||
|
||||
proc changeContactNickname*(self: Controller, publicKey: string, nickname: string) =
|
||||
self.contactsService.changeContactNickname(publicKey, nickname)
|
||||
|
|
|
@ -19,7 +19,9 @@ type
|
|||
ContactIdentityVerification = 13
|
||||
# Local only
|
||||
SystemMessagePinnedMessage = 14
|
||||
SystemMessageMutualStateUpdate = 15
|
||||
SystemMessageMutualEventSent = 15
|
||||
SystemMessageMutualEventAccepted = 16
|
||||
SystemMessageMutualEventRemoved = 17
|
||||
|
||||
proc toContentType*(value: int): ContentType =
|
||||
try:
|
||||
|
|
|
@ -54,6 +54,9 @@ type
|
|||
RpcResponseArgs* = ref object of Args
|
||||
response*: RpcResponse[JsonNode]
|
||||
|
||||
ReloadOneToOneArgs* = ref object of Args
|
||||
sectionId*: string
|
||||
|
||||
# Signals which may be emitted by this service:
|
||||
const SIGNAL_ENS_RESOLVED* = "ensResolved"
|
||||
const SIGNAL_CONTACT_ADDED* = "contactAdded"
|
||||
|
@ -76,7 +79,7 @@ const SIGNAL_CONTACT_VERIFICATION_ACCEPTED* = "contactVerificationRequestAccepte
|
|||
const SIGNAL_CONTACT_VERIFICATION_ADDED* = "contactVerificationRequestAdded"
|
||||
const SIGNAL_CONTACT_VERIFICATION_UPDATED* = "contactVerificationRequestUpdated"
|
||||
const SIGNAL_CONTACT_INFO_REQUEST_FINISHED* = "contactInfoRequestFinished"
|
||||
const SIGNAL_CHAT_REQUEST_UPDATE_AFTER_SEND* = "chatRequestUpdateAfterSend"
|
||||
const SIGNAL_RELOAD_ONE_TO_ONE_CHAT* = "reloadOneToOneChat"
|
||||
|
||||
type
|
||||
ContactsGroup* {.pure.} = enum
|
||||
|
@ -469,7 +472,7 @@ QtObject:
|
|||
|
||||
self.parseContactsResponse(response)
|
||||
self.activityCenterService.parseActivityCenterResponse(response)
|
||||
self.events.emit(SIGNAL_CHAT_REQUEST_UPDATE_AFTER_SEND, RpcResponseArgs(response: response))
|
||||
self.events.emit(SIGNAL_RELOAD_ONE_TO_ONE_CHAT, ReloadOneToOneArgs(sectionId: publicKey))
|
||||
|
||||
except Exception as e:
|
||||
error "an error occurred while sending contact request", msg = e.msg
|
||||
|
@ -489,7 +492,7 @@ QtObject:
|
|||
|
||||
self.parseContactsResponse(response)
|
||||
self.activityCenterService.parseActivityCenterResponse(response)
|
||||
self.events.emit(SIGNAL_CHAT_REQUEST_UPDATE_AFTER_SEND, RpcResponseArgs(response: response))
|
||||
self.events.emit(SIGNAL_RELOAD_ONE_TO_ONE_CHAT, ReloadOneToOneArgs(sectionId: publicKey))
|
||||
|
||||
except Exception as e:
|
||||
error "an error occurred while accepting contact request", msg=e.msg
|
||||
|
@ -509,7 +512,6 @@ QtObject:
|
|||
|
||||
self.parseContactsResponse(response)
|
||||
self.activityCenterService.parseActivityCenterResponse(response)
|
||||
self.events.emit(SIGNAL_CHAT_REQUEST_UPDATE_AFTER_SEND, RpcResponseArgs(response: response))
|
||||
|
||||
except Exception as e:
|
||||
error "an error occurred while dismissing contact request", msg=e.msg
|
||||
|
@ -549,15 +551,15 @@ QtObject:
|
|||
self.parseContactsResponse(response)
|
||||
self.events.emit(SIGNAL_CONTACT_BLOCKED, ContactArgs(contactId: contact.id))
|
||||
|
||||
proc removeContact*(self: Service, publicKey: string): RpcResponse[JsonNode] =
|
||||
proc removeContact*(self: Service, publicKey: string) =
|
||||
let response = status_contacts.retractContactRequest(publicKey)
|
||||
if not response.error.isNil:
|
||||
error "error removing contact ", msg = response.error.message
|
||||
return
|
||||
|
||||
self.events.emit(SIGNAL_RELOAD_ONE_TO_ONE_CHAT, ReloadOneToOneArgs(sectionId: publicKey))
|
||||
self.parseContactsResponse(response)
|
||||
self.activityCenterService.parseActivityCenterResponse(response)
|
||||
return response
|
||||
|
||||
proc ensResolved*(self: Service, jsonObj: string) {.slot.} =
|
||||
let jsonObj = jsonObj.parseJson()
|
||||
|
|
|
@ -265,11 +265,8 @@ QtObject:
|
|||
error "error: received `chats` array for handling messages update is empty"
|
||||
return
|
||||
|
||||
# Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
|
||||
# blocking contact deletes the chat on the `status-go` side, after unblocking it, `active` prop is still false
|
||||
# that's the reason why the following check is commented out here.
|
||||
# if (not chats[0].active):
|
||||
# return
|
||||
if (not chats[0].active):
|
||||
return
|
||||
|
||||
self.bulkReplacePubKeysWithDisplayNames(messages)
|
||||
|
||||
|
@ -383,6 +380,10 @@ QtObject:
|
|||
let data = EnvelopeExpiredArgs(messagesIds: receivedData.messageIds)
|
||||
self.events.emit(SIGNAL_ENVELOPE_EXPIRED, data)
|
||||
|
||||
self.events.on(SIGNAL_RELOAD_ONE_TO_ONE_CHAT) do(e: Args):
|
||||
let args = ReloadOneToOneArgs(e)
|
||||
self.resetMessageCursor(args.sectionId)
|
||||
self.asyncLoadMoreMessagesForChat(args.sectionId)
|
||||
|
||||
self.events.on(SignalType.Message.event) do(e: Args):
|
||||
var receivedData = MessageSignal(e)
|
||||
|
|
|
@ -23,7 +23,9 @@ Control {
|
|||
Invitation = 7,
|
||||
DiscordMessage = 8,
|
||||
SystemMessagePinnedMessage = 14,
|
||||
SystemMessageMutualStateUpdate = 15
|
||||
SystemMessageMutualEventSent = 15,
|
||||
SystemMessageMutualEventAccepted = 16,
|
||||
SystemMessageMutualEventRemoved = 17
|
||||
}
|
||||
|
||||
property list<Item> quickActions
|
||||
|
@ -191,7 +193,9 @@ Control {
|
|||
Layout.fillWidth: true
|
||||
active: isAReply &&
|
||||
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessagePinnedMessage &&
|
||||
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessageMutualStateUpdate
|
||||
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessageMutualEventSent &&
|
||||
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessageMutualEventAccepted &&
|
||||
root.messageDetails.contentType !== StatusMessage.ContentType.SystemMessageMutualEventRemoved
|
||||
|
||||
visible: active
|
||||
sourceComponent: StatusMessageReply {
|
||||
|
|
|
@ -195,8 +195,11 @@ Loader {
|
|||
case Constants.messageContentType.fetchMoreMessagesButton:
|
||||
return fetchMoreMessagesButtonComponent
|
||||
case Constants.messageContentType.systemMessagePrivateGroupType: // no break
|
||||
case Constants.messageContentType.systemMessageMutualStateUpdate:
|
||||
return systemMessageComponent
|
||||
return systemMessageGroupComponent
|
||||
case Constants.messageContentType.systemMessageMutualEventSent:
|
||||
case Constants.messageContentType.systemMessageMutualEventAccepted:
|
||||
case Constants.messageContentType.systemMessageMutualEventRemoved:
|
||||
return systemMessageMutualEventComponent
|
||||
case Constants.messageContentType.systemMessagePinnedMessage:
|
||||
return systemMessagePinnedMessageComponent
|
||||
case Constants.messageContentType.gapType:
|
||||
|
@ -271,8 +274,12 @@ Loader {
|
|||
return StatusMessage.ContentType.DiscordMessage;
|
||||
case Constants.messageContentType.systemMessagePinnedMessage:
|
||||
return StatusMessage.ContentType.SystemMessagePinnedMessage;
|
||||
case Constants.messageContentType.systemMessageMutualStateUpdate:
|
||||
return StatusMessage.ContentType.SystemMessageMutualStateUpdate;
|
||||
case Constants.messageContentType.systemMessageMutualEventSent:
|
||||
return StatusMessage.ContentType.SystemMessageMutualEventSent;
|
||||
case Constants.messageContentType.systemMessageMutualEventAccepted:
|
||||
return StatusMessage.ContentType.SystemMessageMutualEventAccepted;
|
||||
case Constants.messageContentType.systemMessageMutualEventRemoved:
|
||||
return StatusMessage.ContentType.SystemMessageMutualEventRemoved;
|
||||
case Constants.messageContentType.fetchMoreMessagesButton:
|
||||
case Constants.messageContentType.chatIdentifier:
|
||||
case Constants.messageContentType.unknownContentType:
|
||||
|
@ -348,7 +355,7 @@ Loader {
|
|||
}
|
||||
|
||||
Component {
|
||||
id: systemMessageComponent
|
||||
id: systemMessageGroupComponent
|
||||
|
||||
StyledText {
|
||||
wrapMode: Text.Wrap
|
||||
|
@ -379,6 +386,39 @@ Loader {
|
|||
}
|
||||
}
|
||||
|
||||
Component{
|
||||
id: systemMessageMutualEventComponent
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
var displayName = root.amISender ? Utils.getContactDetailsAsJson(chatId, false).displayName : root.senderDisplayName
|
||||
switch (root.messageContentType) {
|
||||
case Constants.messageContentType.systemMessageMutualEventSent:
|
||||
return root.amISender ?
|
||||
qsTr("You sent a contact request to %1").arg(displayName) :
|
||||
qsTr("%1 sent you a contact request").arg(displayName)
|
||||
case Constants.messageContentType.systemMessageMutualEventAccepted:
|
||||
return root.amISender ?
|
||||
qsTr("You accepted %1's contact request").arg(displayName) :
|
||||
qsTr("%1 accepted your contact request").arg(displayName)
|
||||
case Constants.messageContentType.systemMessageMutualEventRemoved:
|
||||
return root.amISender ?
|
||||
qsTr("You removed %1 as a contact").arg(displayName) :
|
||||
qsTr("%1 removed you as a contact").arg(displayName)
|
||||
default:
|
||||
return root.messageText
|
||||
}
|
||||
}
|
||||
font.pixelSize: 14
|
||||
color: Style.current.secondaryText
|
||||
width: parent.width - 120
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
textFormat: Text.RichText
|
||||
topPadding: root.prevMessageIndex === 1 ? Style.current.bigPadding : 0
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: systemMessagePinnedMessageComponent
|
||||
|
||||
|
@ -481,7 +521,9 @@ Loader {
|
|||
showHeader: root.shouldRepeatHeader || dateGroupLabel.visible || isAReply ||
|
||||
root.prevMessageContentType === Constants.messageContentType.systemMessagePrivateGroupType ||
|
||||
root.prevMessageContentType === Constants.messageContentType.systemMessagePinnedMessage ||
|
||||
root.prevMessageContentType === Constants.messageContentType.systemMessageMutualStateUpdate ||
|
||||
root.prevMessageContentType === Constants.messageContentType.systemMessageMutualEventSent ||
|
||||
root.prevMessageContentType === Constants.messageContentType.systemMessageMutualEventAccepted ||
|
||||
root.prevMessageContentType === Constants.messageContentType.systemMessageMutualEventRemoved ||
|
||||
root.senderId !== root.prevMessageSenderId
|
||||
isActiveMessage: d.isMessageActive
|
||||
topPadding: showHeader ? Style.current.halfPadding : 0
|
||||
|
|
|
@ -430,7 +430,9 @@ QtObject {
|
|||
readonly property int contactRequestType: 11
|
||||
readonly property int discordMessageType: 12
|
||||
readonly property int systemMessagePinnedMessage: 14
|
||||
readonly property int systemMessageMutualStateUpdate: 15
|
||||
readonly property int systemMessageMutualEventSent: 15
|
||||
readonly property int systemMessageMutualEventAccepted: 16
|
||||
readonly property int systemMessageMutualEventRemoved: 17
|
||||
}
|
||||
|
||||
readonly property QtObject messageModelRoles: QtObject {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ff0628c23b12166e21d95b58d9a7abf696fd902a
|
||||
Subproject commit 9ee523be99483a14f83c3e7a74220d5695ee755a
|
Loading…
Reference in New Issue