support removing contacts
support removing contacts support removing contacts
This commit is contained in:
parent
ce7e6b8d51
commit
a6493725b6
|
@ -156,6 +156,9 @@ QtObject:
|
|||
proc addContact*(self: ChatsView, id: string): string {.slot.} =
|
||||
return self.status.contacts.addContact(id)
|
||||
|
||||
proc removeContact*(self: ChatsView, id: string) {.slot.} =
|
||||
self.status.contacts.removeContact(id)
|
||||
|
||||
proc createGroup*(self: ChatsView, groupName: string, pubKeys: string) {.slot.} =
|
||||
let pubKeysSeq = map(parseJson(pubKeys).getElems(), proc(x:JsonNode):string = x.getStr)
|
||||
self.status.chat.createGroup(groupName, pubKeysSeq)
|
||||
|
|
|
@ -50,6 +50,10 @@ proc init*(self: ProfileController, account: Account) =
|
|||
let contacts = self.status.contacts.getContacts()
|
||||
self.view.setContactList(contacts)
|
||||
|
||||
self.status.events.on("contactRemoved") do(e: Args):
|
||||
let contacts = self.status.contacts.getContacts()
|
||||
self.view.setContactList(contacts)
|
||||
|
||||
method onSignal(self: ProfileController, data: Signal) =
|
||||
let msgData = MessageSignal(data);
|
||||
if msgData.contacts.len > 0:
|
||||
|
|
|
@ -4,6 +4,7 @@ import views/contact_list
|
|||
import views/profile_info
|
||||
import ../../status/profile/[mailserver, profile]
|
||||
import ../../status/profile as status_profile
|
||||
import ../../status/contacts as status_contacts
|
||||
import ../../status/accounts as status_accounts
|
||||
import ../../status/status
|
||||
import ../../status/chat/chat
|
||||
|
@ -71,3 +72,7 @@ QtObject:
|
|||
|
||||
proc nodeVersion*(self: ProfileView): string {.slot.} =
|
||||
self.status.getNodeVersion()
|
||||
|
||||
proc isAdded*(self: ProfileView, id: string): bool {.slot.} =
|
||||
if id == "": return false
|
||||
self.status.contacts.isAdded(id)
|
||||
|
|
|
@ -34,3 +34,13 @@ proc addContact*(self: ContactModel, id: string): string =
|
|||
contact.systemTags.add(":contact/added")
|
||||
result = status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensVerifiedAt, contact.ensVerificationRetries, contact.alias, contact.identicon, contact.systemTags)
|
||||
self.events.emit("contactAdded", Args())
|
||||
|
||||
proc removeContact*(self: ContactModel, id: string) =
|
||||
let contact = self.getContactByID(id)
|
||||
contact.systemTags.delete(contact.systemTags.find(":contact/added"))
|
||||
discard status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensVerifiedAt, contact.ensVerificationRetries, contact.alias, contact.identicon, contact.systemTags)
|
||||
self.events.emit("contactRemoved", Args())
|
||||
|
||||
proc isAdded*(self: ContactModel, id: string): bool =
|
||||
var contact = self.getContactByID(id)
|
||||
contact.systemTags.contains(":contact/added")
|
||||
|
|
|
@ -240,12 +240,14 @@ ModalPopup {
|
|||
id: addToContactsButton
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.smallPadding
|
||||
label: qsTr("Add to contacts")
|
||||
label: profileModel.isAdded(fromAuthor) ? qsTr("Remove Contact") : qsTr("Add to contacts")
|
||||
anchors.bottom: parent.bottom
|
||||
onClicked: {
|
||||
if (profileModel.isAdded(fromAuthor)) {
|
||||
chatsModel.removeContact(fromAuthor)
|
||||
} else {
|
||||
chatsModel.addContact(fromAuthor)
|
||||
// TODO(iuri): Change add contact button state based
|
||||
// on contact already added or not
|
||||
}
|
||||
profilePopup.close()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue