fix(block): remove chat and messages when blocking a contact (#16889)
Fixes #16640 This makes it so that when you block a contact, it now also removes the chat and the messages as expected by the requirements and as Mobile does. To do so, I use the same API as mobile instead of the forked desktop one. I removed the desktop one as it is no longer needed (see status-go PR) I also fixed an issue when unblocking where it would send a double toast messages with one saying you "removed the contact", but it was already removed.
This commit is contained in:
parent
ac3d609bd8
commit
1735d7e75a
|
@ -882,7 +882,7 @@ method onCategoryNameChanged*(self: Module, category: Category) =
|
|||
self.view.chatsModel().renameCategory(category.id, category.name)
|
||||
|
||||
method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) =
|
||||
if(not self.chatContentModules.contains(chatId)):
|
||||
if not self.chatContentModules.contains(chatId):
|
||||
return
|
||||
self.view.chatsModel().removeItemById(chatId)
|
||||
self.removeSubmodule(chatId)
|
||||
|
@ -1197,6 +1197,7 @@ method blockContact*(self: Module, publicKey: string) =
|
|||
method onContactBlocked*(self: Module, publicKey: string) =
|
||||
self.view.contactRequestsModel().removeItemById(publicKey)
|
||||
self.view.chatsModel().changeBlockedOnItemById(publicKey, blocked=true)
|
||||
self.onCommunityChannelDeletedOrChatLeft(publicKey)
|
||||
|
||||
method onContactUnblocked*(self: Module, publicKey: string) =
|
||||
self.view.chatsModel().changeBlockedOnItemById(publicKey, blocked=false)
|
||||
|
|
|
@ -84,9 +84,6 @@ type
|
|||
role*: MemberRole
|
||||
joined*: bool
|
||||
|
||||
RpcResponseArgs* = ref object of Args
|
||||
response*: RpcResponse[JsonNode]
|
||||
|
||||
CheckChannelPermissionsResponseArgs* = ref object of Args
|
||||
communityId*: string
|
||||
chatId*: string
|
||||
|
@ -120,7 +117,6 @@ const SIGNAL_CHAT_MEMBER_UPDATED* = "chatMemberUpdated"
|
|||
const SIGNAL_CHAT_SWITCH_TO_OR_CREATE_1_1_CHAT* = "switchToOrCreateOneToOneChat"
|
||||
const SIGNAL_CHAT_ADDED_OR_UPDATED* = "chatAddedOrUpdated"
|
||||
const SIGNAL_CHAT_CREATED* = "chatCreated"
|
||||
const SIGNAL_CHAT_REQUEST_UPDATE_AFTER_SEND* = "chatRequestUpdateAfterSend"
|
||||
const SIGNAL_CHECK_CHANNEL_PERMISSIONS_RESPONSE* = "checkChannelPermissionsResponse"
|
||||
const SIGNAL_CHECK_ALL_CHANNELS_PERMISSIONS_RESPONSE* = "checkAllChannelsPermissionsResponse"
|
||||
const SIGNAL_CHECK_ALL_CHANNELS_PERMISSIONS_FAILED* = "checkAllChannelsPermissionsFailed"
|
||||
|
@ -183,10 +179,6 @@ QtObject:
|
|||
for clearedHistoryDto in receivedData.clearedHistories:
|
||||
self.events.emit(SIGNAL_CHAT_HISTORY_CLEARED, ChatArgs(chatId: clearedHistoryDto.chatId))
|
||||
|
||||
self.events.on(SIGNAL_CHAT_REQUEST_UPDATE_AFTER_SEND) do(e: Args):
|
||||
var args = RpcResponseArgs(e)
|
||||
discard self.processMessengerResponse(args.response)
|
||||
|
||||
proc asyncGetActiveChats*(self: Service) =
|
||||
let arg = AsyncGetActiveChatsTaskArg(
|
||||
tptr: asyncGetActiveChatsTask,
|
||||
|
|
|
@ -52,9 +52,6 @@ type
|
|||
publicKey*: string
|
||||
ok*: bool
|
||||
|
||||
RpcResponseArgs* = ref object of Args
|
||||
response*: RpcResponse[JsonNode]
|
||||
|
||||
AppendChatMessagesArgs* = ref object of Args
|
||||
chatId*: string
|
||||
messages*: JsonNode
|
||||
|
@ -395,9 +392,9 @@ QtObject:
|
|||
if self.contacts.hasKey(publicKey):
|
||||
if self.contacts[publicKey].dto.added and not self.contacts[publicKey].dto.removed and contact.added and not contact.removed:
|
||||
signal = SIGNAL_CONTACT_UPDATED
|
||||
if contact.removed:
|
||||
singletonInstance.globalEvents.showContactRemoved("Contact removed", fmt "You removed {contact.displayName} as a contact", contact.id)
|
||||
signal = SIGNAL_CONTACT_REMOVED
|
||||
if contact.removed and not self.contacts[publicKey].dto.removed:
|
||||
singletonInstance.globalEvents.showContactRemoved("Contact removed", fmt "You removed {contact.displayName} as a contact", contact.id)
|
||||
signal = SIGNAL_CONTACT_REMOVED
|
||||
|
||||
self.contacts[publicKey] = self.constructContactDetails(contact)
|
||||
self.events.emit(signal, ContactArgs(contactId: publicKey))
|
||||
|
|
|
@ -9,7 +9,7 @@ proc getContacts*(): RpcResponse[JsonNode] =
|
|||
result = callPrivateRPC("contacts".prefix, payload)
|
||||
|
||||
proc blockContact*(id: string): RpcResponse[JsonNode] =
|
||||
result = callPrivateRPC("blockContactDesktop".prefix, %* [id])
|
||||
result = callPrivateRPC("blockContact".prefix, %* [id])
|
||||
|
||||
proc unblockContact*(id: string): RpcResponse[JsonNode] =
|
||||
result = callPrivateRPC("unblockContact".prefix, %* [id])
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c27c773c27a10d0dd7742d324455ca7143829065
|
||||
Subproject commit d291204473d2dcdb27062f017ffe9966463d4818
|
Loading…
Reference in New Issue