fix(@desktop/profile): chat confirmation notification
fixes #2637 When changing a contact, the notification about being able to chat was sent again. Prevent this behaviour by ensuring the contact hasn't already been added
This commit is contained in:
parent
d10ffd56ce
commit
b31bd265c5
|
@ -119,9 +119,8 @@ proc init*(self: ProfileController, account: Account) =
|
||||||
let msgData = MessageSignal(e);
|
let msgData = MessageSignal(e);
|
||||||
if msgData.contacts.len > 0:
|
if msgData.contacts.len > 0:
|
||||||
# TODO: view should react to model changes
|
# TODO: view should react to model changes
|
||||||
self.status.chat.updateContacts(msgData.contacts)
|
|
||||||
self.view.contacts.updateContactList(msgData.contacts)
|
self.view.contacts.updateContactList(msgData.contacts)
|
||||||
self.view.contacts.notifyOnNewContactRequests(msgData.contacts)
|
self.status.chat.updateContacts(msgData.contacts)
|
||||||
if msgData.installations.len > 0:
|
if msgData.installations.len > 0:
|
||||||
self.view.devices.addDevices(msgData.installations)
|
self.view.devices.addDevices(msgData.installations)
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,7 @@ QtObject:
|
||||||
c.ensName = contact.ensName
|
c.ensName = contact.ensName
|
||||||
c.ensVerified = contact.ensVerified
|
c.ensVerified = contact.ensVerified
|
||||||
c.identityImage = contact.identityImage
|
c.identityImage = contact.identityImage
|
||||||
|
c.systemTags = contact.systemTags
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
self.addContactToList(contact)
|
self.addContactToList(contact)
|
||||||
|
|
|
@ -64,16 +64,26 @@ QtObject:
|
||||||
result.setup
|
result.setup
|
||||||
|
|
||||||
proc contactListChanged*(self: ContactsView) {.signal.}
|
proc contactListChanged*(self: ContactsView) {.signal.}
|
||||||
|
proc contactRequestAdded*(self: ContactsView, name: string, address: string) {.signal.}
|
||||||
|
|
||||||
proc updateContactList*(self: ContactsView, contacts: seq[Profile]) =
|
proc updateContactList*(self: ContactsView, contacts: seq[Profile]) =
|
||||||
for contact in contacts:
|
for contact in contacts:
|
||||||
|
var requestAlreadyAdded = false
|
||||||
|
for existingContact in self.contactList.contacts:
|
||||||
|
if existingContact.address == contact.address and existingContact.requestReceived():
|
||||||
|
requestAlreadyAdded = true
|
||||||
|
break
|
||||||
|
|
||||||
self.contactList.updateContact(contact)
|
self.contactList.updateContact(contact)
|
||||||
if contact.systemTags.contains(contactAdded):
|
if contact.systemTags.contains(contactAdded):
|
||||||
self.addedContacts.updateContact(contact)
|
self.addedContacts.updateContact(contact)
|
||||||
if contact.systemTags.contains(contactBlocked):
|
if contact.isBlocked():
|
||||||
self.blockedContacts.updateContact(contact)
|
self.blockedContacts.updateContact(contact)
|
||||||
if contact.systemTags.contains(contactRequest) and not contact.systemTags.contains(contactAdded) and not contact.systemTags.contains(contactBlocked):
|
if contact.requestReceived() and not contact.systemTags.contains(contactAdded) and not contact.systemTags.contains(contactBlocked):
|
||||||
self.contactRequests.updateContact(contact)
|
self.contactRequests.updateContact(contact)
|
||||||
|
if not requestAlreadyAdded and contact.requestReceived():
|
||||||
|
self.contactRequestAdded(status_ens.userNameOrAlias(contact), contact.address)
|
||||||
|
|
||||||
self.contactListChanged()
|
self.contactListChanged()
|
||||||
|
|
||||||
proc getContactList(self: ContactsView): QVariant {.slot.} =
|
proc getContactList(self: ContactsView): QVariant {.slot.} =
|
||||||
|
@ -86,13 +96,6 @@ QtObject:
|
||||||
self.contactRequests.setNewData(contactList.filter(c => c.systemTags.contains(contactRequest) and not c.systemTags.contains(contactAdded) and not c.systemTags.contains(contactBlocked)))
|
self.contactRequests.setNewData(contactList.filter(c => c.systemTags.contains(contactRequest) and not c.systemTags.contains(contactAdded) and not c.systemTags.contains(contactBlocked)))
|
||||||
self.contactListChanged()
|
self.contactListChanged()
|
||||||
|
|
||||||
proc contactRequestAdded*(self: ContactsView, name: string, address: string) {.signal.}
|
|
||||||
|
|
||||||
proc notifyOnNewContactRequests*(self: ContactsView, contacts: seq[Profile]) =
|
|
||||||
for contact in contacts:
|
|
||||||
if contact.systemTags.contains(contactRequest) and not contact.systemTags.contains(contactBlocked):
|
|
||||||
self.contactRequestAdded(status_ens.userNameOrAlias(contact), contact.address)
|
|
||||||
|
|
||||||
QtProperty[QVariant] list:
|
QtProperty[QVariant] list:
|
||||||
read = getContactList
|
read = getContactList
|
||||||
write = setContactList
|
write = setContactList
|
||||||
|
|
Loading…
Reference in New Issue