fix(Contacts): Resolve edge cases while addind/removing a contact
This commit is contained in:
parent
e160e70121
commit
8ff42d0868
|
@ -129,22 +129,20 @@ proc addItemToAppropriateModel(self: Module, item: UserItem) =
|
|||
if(singletonInstance.userProfile.getPubKey() == item.pubKey):
|
||||
return
|
||||
let contact = self.controller.getContact(item.pubKey())
|
||||
if(contact.isContactRemoved()):
|
||||
return
|
||||
elif(contact.isBlocked()):
|
||||
|
||||
if contact.isBlocked():
|
||||
self.view.blockedContactsModel().addItem(item)
|
||||
elif(contact.isContact()):
|
||||
self.view.myMutualContactsModel().addItem(item)
|
||||
else:
|
||||
if(contact.isContactRequestReceived() and not contact.isContactRequestSent()):
|
||||
return
|
||||
|
||||
case contact.requestState:
|
||||
of ContactRequestState.Received:
|
||||
self.view.receivedContactRequestsModel().addItem(item)
|
||||
elif(contact.isContactRequestSent() and not contact.isContactRequestReceived()):
|
||||
of ContactRequestState.Sent:
|
||||
self.view.sentContactRequestsModel().addItem(item)
|
||||
# Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
|
||||
# elif(contact.isContactRequestReceived() and contact.isReceivedContactRequestRejected()):
|
||||
# self.view.receivedButRejectedContactRequestsModel().addItem(item)
|
||||
# elif(contact.isContactRequestSent() and contact.isSentContactRequestRejected()):
|
||||
# self.view.sentButRejectedContactRequestsModel().addItem(item)
|
||||
of ContactRequestState.Mutual:
|
||||
self.view.myMutualContactsModel().addItem(item)
|
||||
else:
|
||||
return
|
||||
|
||||
proc removeItemWithPubKeyFromAllModels(self: Module, publicKey: string) =
|
||||
self.view.myMutualContactsModel().removeItemById(publicKey)
|
||||
|
@ -172,9 +170,6 @@ method contactUnblocked*(self: Module, publicKey: string) =
|
|||
method contactRemoved*(self: Module, publicKey: string) =
|
||||
self.removeIfExistsAndAddToAppropriateModel(publicKey)
|
||||
|
||||
method contactRequestRejectionRemoved*(self: Module, publicKey: string) =
|
||||
self.removeIfExistsAndAddToAppropriateModel(publicKey)
|
||||
|
||||
method contactUpdated*(self: Module, publicKey: string) =
|
||||
self.removeIfExistsAndAddToAppropriateModel(publicKey)
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ QtObject:
|
|||
self.endResetModel()
|
||||
self.countChanged()
|
||||
|
||||
for item in items:
|
||||
self.itemChanged(item.pubKey)
|
||||
|
||||
proc `$`*(self: Model): string =
|
||||
for i in 0 ..< self.items.len:
|
||||
result &= fmt"""User Model:
|
||||
|
|
|
@ -358,6 +358,10 @@ Pane {
|
|||
if (d.isCurrentUser)
|
||||
return btnEditProfileComponent
|
||||
|
||||
// blocked contact
|
||||
if (d.isBlocked)
|
||||
return btnUnblockUserComponent
|
||||
|
||||
// contact request, outgoing, rejected
|
||||
if (!d.isContact && d.isContactRequestSent && d.outgoingVerificationStatus === Constants.verificationStatus.declined)
|
||||
return txtRejectedContactRequestComponent
|
||||
|
@ -388,10 +392,6 @@ Pane {
|
|||
if (!d.isContact && !d.isBlocked && !d.isContactRequestSent)
|
||||
return btnSendContactRequestComponent
|
||||
|
||||
// blocked contact
|
||||
if (d.isBlocked)
|
||||
return btnUnblockUserComponent
|
||||
|
||||
// send message
|
||||
if (d.isContact && !d.isBlocked)
|
||||
return btnSendMessageComponent
|
||||
|
|
Loading…
Reference in New Issue