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:
parent
7c735aa7a8
commit
728a97389d
|
@ -2,9 +2,10 @@ import # std libs
|
||||||
strutils
|
strutils
|
||||||
|
|
||||||
import # status-desktop libs
|
import # status-desktop libs
|
||||||
../../status/chat/chat as status_chat, ./views/communities,
|
../../status/chat/chat as status_chat,
|
||||||
../../status/tasks/marathon,
|
../../status/tasks/marathon,
|
||||||
../../status/tasks/marathon/mailserver/worker,
|
../../status/tasks/marathon/mailserver/worker,
|
||||||
|
./views/communities,
|
||||||
./views/messages
|
./views/messages
|
||||||
|
|
||||||
proc handleChatEvents(self: ChatController) =
|
proc handleChatEvents(self: ChatController) =
|
||||||
|
@ -27,6 +28,10 @@ proc handleChatEvents(self: ChatController) =
|
||||||
self.view.pushActivityCenterNotifications(notifications)
|
self.view.pushActivityCenterNotifications(notifications)
|
||||||
self.view.communities.updateNotifications(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):
|
self.status.events.on("contactUpdate") do(e: Args):
|
||||||
var evArgs = ContactUpdateArgs(e)
|
var evArgs = ContactUpdateArgs(e)
|
||||||
self.view.updateUsernames(evArgs.contacts)
|
self.view.updateUsernames(evArgs.contacts)
|
||||||
|
|
|
@ -15,6 +15,9 @@ type
|
||||||
ContactUpdateArgs* = ref object of Args
|
ContactUpdateArgs* = ref object of Args
|
||||||
contacts*: seq[Profile]
|
contacts*: seq[Profile]
|
||||||
|
|
||||||
|
ContactBlockedArgs* = ref object of Args
|
||||||
|
contact*: Profile
|
||||||
|
|
||||||
proc newContactModel*(events: EventEmitter): ContactModel =
|
proc newContactModel*(events: EventEmitter): ContactModel =
|
||||||
result = ContactModel()
|
result = ContactModel()
|
||||||
result.events = events
|
result.events = events
|
||||||
|
@ -35,7 +38,7 @@ proc blockContact*(self: ContactModel, id: string): string =
|
||||||
if (index > -1):
|
if (index > -1):
|
||||||
contact.systemTags.delete(index)
|
contact.systemTags.delete(index)
|
||||||
discard status_contacts.blockContact(contact)
|
discard status_contacts.blockContact(contact)
|
||||||
self.events.emit("contactBlocked", Args())
|
self.events.emit("contactBlocked", ContactBlockedArgs(contact: contact))
|
||||||
|
|
||||||
|
|
||||||
proc unblockContact*(self: ContactModel, id: string): string =
|
proc unblockContact*(self: ContactModel, id: string): string =
|
||||||
|
|
Loading…
Reference in New Issue