diff --git a/src/app/modules/main/profile_section/contacts/module.nim b/src/app/modules/main/profile_section/contacts/module.nim index 2d4d74d81a..e90f202fed 100644 --- a/src/app/modules/main/profile_section/contacts/module.nim +++ b/src/app/modules/main/profile_section/contacts/module.nim @@ -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) diff --git a/src/app/modules/shared_models/user_model.nim b/src/app/modules/shared_models/user_model.nim index cb772a57cc..1b23809b9c 100644 --- a/src/app/modules/shared_models/user_model.nim +++ b/src/app/modules/shared_models/user_model.nim @@ -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: diff --git a/ui/imports/shared/views/ProfileDialogView.qml b/ui/imports/shared/views/ProfileDialogView.qml index 0180c08d12..60802c3c31 100644 --- a/ui/imports/shared/views/ProfileDialogView.qml +++ b/ui/imports/shared/views/ProfileDialogView.qml @@ -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