fix(@desktop/profile): remove chat when blocking contact

fixes #2708

When blocking a contact, if there is a chat open, close it
This commit is contained in:
Anthony Laibe 2021-08-03 11:26:43 +02:00 committed by Iuri Matias
parent 7c735aa7a8
commit 728a97389d
2 changed files with 10 additions and 2 deletions

View File

@ -2,9 +2,10 @@ import # std libs
strutils
import # status-desktop libs
../../status/chat/chat as status_chat, ./views/communities,
../../status/chat/chat as status_chat,
../../status/tasks/marathon,
../../status/tasks/marathon/mailserver/worker,
./views/communities,
./views/messages
proc handleChatEvents(self: ChatController) =
@ -27,6 +28,10 @@ proc handleChatEvents(self: ChatController) =
self.view.pushActivityCenterNotifications(notifications)
self.view.communities.updateNotifications(notifications)
self.status.events.on("contactBlocked") do(e: Args):
var evArgs = ContactBlockedArgs(e)
self.view.removeChat(evArgs.contact.address)
self.status.events.on("contactUpdate") do(e: Args):
var evArgs = ContactUpdateArgs(e)
self.view.updateUsernames(evArgs.contacts)

View File

@ -15,6 +15,9 @@ type
ContactUpdateArgs* = ref object of Args
contacts*: seq[Profile]
ContactBlockedArgs* = ref object of Args
contact*: Profile
proc newContactModel*(events: EventEmitter): ContactModel =
result = ContactModel()
result.events = events
@ -35,7 +38,7 @@ proc blockContact*(self: ContactModel, id: string): string =
if (index > -1):
contact.systemTags.delete(index)
discard status_contacts.blockContact(contact)
self.events.emit("contactBlocked", Args())
self.events.emit("contactBlocked", ContactBlockedArgs(contact: contact))
proc unblockContact*(self: ContactModel, id: string): string =