parent
c8cc65506b
commit
fb47d73e79
|
@ -168,7 +168,7 @@ QtObject:
|
||||||
var nicknameToSet = nickname
|
var nicknameToSet = nickname
|
||||||
if (nicknameToSet == ""):
|
if (nicknameToSet == ""):
|
||||||
nicknameToSet = DELETE_CONTACT
|
nicknameToSet = DELETE_CONTACT
|
||||||
discard self.status.contacts.addContact(publicKey, nicknameToSet)
|
discard self.status.contacts.setNickName(publicKey, nicknameToSet)
|
||||||
|
|
||||||
proc unblockContact*(self: ContactsView, publicKey: string) {.slot.} =
|
proc unblockContact*(self: ContactsView, publicKey: string) {.slot.} =
|
||||||
self.contactListChanged()
|
self.contactListChanged()
|
||||||
|
|
|
@ -53,13 +53,14 @@ proc getContacts*(self: ContactModel): seq[Profile] =
|
||||||
result = getAllContacts()
|
result = getAllContacts()
|
||||||
self.events.emit("contactUpdate", ContactUpdateArgs(contacts: result))
|
self.events.emit("contactUpdate", ContactUpdateArgs(contacts: result))
|
||||||
|
|
||||||
proc addContact*(self: ContactModel, id: string, localNickname: string): string =
|
proc getOrCreateContact*(self: ContactModel, id: string): Profile =
|
||||||
var contact = self.getContactByID(id)
|
result = self.getContactByID(id)
|
||||||
if contact == nil:
|
if result == nil:
|
||||||
let alias = status_accounts.generateAlias(id)
|
let alias = status_accounts.generateAlias(id)
|
||||||
contact = Profile(
|
result = Profile(
|
||||||
id: id,
|
id: id,
|
||||||
username: alias,
|
username: alias,
|
||||||
|
localNickname: "",
|
||||||
identicon: status_accounts.generateIdenticon(id),
|
identicon: status_accounts.generateIdenticon(id),
|
||||||
alias: alias,
|
alias: alias,
|
||||||
ensName: "",
|
ensName: "",
|
||||||
|
@ -68,10 +69,8 @@ proc addContact*(self: ContactModel, id: string, localNickname: string): string
|
||||||
systemTags: @[]
|
systemTags: @[]
|
||||||
)
|
)
|
||||||
|
|
||||||
let updating = contact.systemTags.contains(":contact/added")
|
proc setNickName*(self: ContactModel, id: string, localNickname: string): string =
|
||||||
if not updating:
|
var contact = self.getOrCreateContact(id)
|
||||||
contact.systemTags.add(":contact/added")
|
|
||||||
discard status_chat.createProfileChat(contact.id)
|
|
||||||
let nickname =
|
let nickname =
|
||||||
if (localNickname == ""):
|
if (localNickname == ""):
|
||||||
contact.localNickname
|
contact.localNickname
|
||||||
|
@ -83,11 +82,25 @@ proc addContact*(self: ContactModel, id: string, localNickname: string): string
|
||||||
var thumbnail = ""
|
var thumbnail = ""
|
||||||
if contact.identityImage != nil:
|
if contact.identityImage != nil:
|
||||||
thumbnail = contact.identityImage.thumbnail
|
thumbnail = contact.identityImage.thumbnail
|
||||||
|
|
||||||
result = status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.alias, contact.identicon, thumbnail, contact.systemTags, nickname)
|
result = status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.alias, contact.identicon, thumbnail, contact.systemTags, nickname)
|
||||||
self.events.emit("contactAdded", Args())
|
self.events.emit("contactAdded", Args())
|
||||||
discard requestContactUpdate(contact.id)
|
discard requestContactUpdate(contact.id)
|
||||||
|
|
||||||
|
|
||||||
|
proc addContact*(self: ContactModel, id: string): string =
|
||||||
|
var contact = self.getOrCreateContact(id)
|
||||||
|
let updating = contact.systemTags.contains(":contact/added")
|
||||||
|
if not updating:
|
||||||
|
contact.systemTags.add(":contact/added")
|
||||||
|
discard status_chat.createProfileChat(contact.id)
|
||||||
|
var thumbnail = ""
|
||||||
|
if contact.identityImage != nil:
|
||||||
|
thumbnail = contact.identityImage.thumbnail
|
||||||
|
|
||||||
|
result = status_contacts.saveContact(contact.id, contact.ensVerified, contact.ensName, contact.alias, contact.identicon, thumbnail, contact.systemTags, contact.localNickname)
|
||||||
|
self.events.emit("contactAdded", Args())
|
||||||
|
discard requestContactUpdate(contact.id)
|
||||||
|
|
||||||
if updating:
|
if updating:
|
||||||
let profile = Profile(
|
let profile = Profile(
|
||||||
id: contact.id,
|
id: contact.id,
|
||||||
|
@ -98,13 +111,10 @@ proc addContact*(self: ContactModel, id: string, localNickname: string): string
|
||||||
ensVerified: contact.ensVerified,
|
ensVerified: contact.ensVerified,
|
||||||
appearance: 0,
|
appearance: 0,
|
||||||
systemTags: contact.systemTags,
|
systemTags: contact.systemTags,
|
||||||
localNickname: nickname
|
localNickname: contact.localNickname
|
||||||
)
|
)
|
||||||
self.events.emit("contactUpdate", ContactUpdateArgs(contacts: @[profile]))
|
self.events.emit("contactUpdate", ContactUpdateArgs(contacts: @[profile]))
|
||||||
|
|
||||||
proc addContact*(self: ContactModel, id: string): string =
|
|
||||||
result = self.addContact(id, "")
|
|
||||||
|
|
||||||
proc removeContact*(self: ContactModel, id: string) =
|
proc removeContact*(self: ContactModel, id: string) =
|
||||||
let contact = self.getContactByID(id)
|
let contact = self.getContactByID(id)
|
||||||
contact.systemTags.delete(contact.systemTags.find(":contact/added"))
|
contact.systemTags.delete(contact.systemTags.find(":contact/added"))
|
||||||
|
|
Loading…
Reference in New Issue