fix(@desktop/contacts): multiple contact related issues fixed

Fixes #5354 #5225 #5198
This commit is contained in:
Sale Djenic 2022-04-08 22:17:16 +02:00 committed by Iuri Matias
parent 31728940c4
commit 3cdc1358ba
9 changed files with 149 additions and 120 deletions

View File

@ -64,8 +64,9 @@ method viewDidLoad*(self: Module) =
self.buildModel(self.view.blockedContactsModel(), ContactsGroup.BlockedContacts) self.buildModel(self.view.blockedContactsModel(), ContactsGroup.BlockedContacts)
self.buildModel(self.view.receivedContactRequestsModel(), ContactsGroup.IncomingPendingContactRequests) self.buildModel(self.view.receivedContactRequestsModel(), ContactsGroup.IncomingPendingContactRequests)
self.buildModel(self.view.sentContactRequestsModel(), ContactsGroup.OutgoingPendingContactRequests) self.buildModel(self.view.sentContactRequestsModel(), ContactsGroup.OutgoingPendingContactRequests)
self.buildModel(self.view.receivedButRejectedContactRequestsModel(), ContactsGroup.IncomingRejectedContactRequests) # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
self.buildModel(self.view.sentButRejectedContactRequestsModel(), ContactsGroup.IncomingRejectedContactRequests) # self.buildModel(self.view.receivedButRejectedContactRequestsModel(), ContactsGroup.IncomingRejectedContactRequests)
# self.buildModel(self.view.sentButRejectedContactRequestsModel(), ContactsGroup.IncomingRejectedContactRequests)
self.moduleLoaded = true self.moduleLoaded = true
self.delegate.contactsModuleDidLoad() self.delegate.contactsModuleDidLoad()
@ -95,27 +96,33 @@ method removeContactRequestRejection*(self: Module, publicKey: string) =
self.controller.removeContactRequestRejection(publicKey) self.controller.removeContactRequestRejection(publicKey)
proc addItemToAppropriateModel(self: Module, item: Item) = proc addItemToAppropriateModel(self: Module, item: Item) =
if(item.isBlocked()): if(singletonInstance.userProfile.getPubKey() == item.pubKey):
return
let contact = self.controller.getContact(item.pubKey())
if(contact.isContactRemoved()):
return
elif(contact.isBlocked()):
self.view.blockedContactsModel().addItem(item) self.view.blockedContactsModel().addItem(item)
elif(item.isMutualContact()): elif(contact.isMutualContact()):
self.view.myMutualContactsModel().addItem(item) self.view.myMutualContactsModel().addItem(item)
else: else:
let contact = self.controller.getContact(item.pubKey()) if(contact.isContactRequestReceived() and not contact.isContactRequestSent()):
if(contact.isContactRequestReceived() and not contact.isContactRequestSent() and not contact.isReceivedContactRequestRejected()):
self.view.receivedContactRequestsModel().addItem(item) self.view.receivedContactRequestsModel().addItem(item)
elif(contact.isContactRequestSent() and not contact.isContactRequestReceived() and not contact.isSentContactRequestRejected() and singletonInstance.userProfile.getPubKey() != item.pubKey): elif(contact.isContactRequestSent() and not contact.isContactRequestReceived()):
self.view.sentContactRequestsModel().addItem(item) self.view.sentContactRequestsModel().addItem(item)
elif(contact.isContactRequestReceived() and contact.isReceivedContactRequestRejected()): # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
self.view.receivedButRejectedContactRequestsModel().addItem(item) # elif(contact.isContactRequestReceived() and contact.isReceivedContactRequestRejected()):
elif(contact.isContactRequestSent() and contact.isSentContactRequestRejected()): # self.view.receivedButRejectedContactRequestsModel().addItem(item)
self.view.sentButRejectedContactRequestsModel().addItem(item) # elif(contact.isContactRequestSent() and contact.isSentContactRequestRejected()):
# self.view.sentButRejectedContactRequestsModel().addItem(item)
proc removeItemWithPubKeyFromAllModels(self: Module, publicKey: string) = proc removeItemWithPubKeyFromAllModels(self: Module, publicKey: string) =
self.view.myMutualContactsModel().removeItemWithPubKey(publicKey) self.view.myMutualContactsModel().removeItemWithPubKey(publicKey)
self.view.receivedContactRequestsModel().removeItemWithPubKey(publicKey) self.view.receivedContactRequestsModel().removeItemWithPubKey(publicKey)
self.view.sentContactRequestsModel().removeItemWithPubKey(publicKey) self.view.sentContactRequestsModel().removeItemWithPubKey(publicKey)
self.view.receivedButRejectedContactRequestsModel().removeItemWithPubKey(publicKey) # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
self.view.sentButRejectedContactRequestsModel().removeItemWithPubKey(publicKey) # self.view.receivedButRejectedContactRequestsModel().removeItemWithPubKey(publicKey)
# self.view.sentButRejectedContactRequestsModel().removeItemWithPubKey(publicKey)
self.view.blockedContactsModel().removeItemWithPubKey(publicKey) self.view.blockedContactsModel().removeItemWithPubKey(publicKey)
method removeIfExistsAndAddToAppropriateModel*(self: Module, publicKey: string) = method removeIfExistsAndAddToAppropriateModel*(self: Module, publicKey: string) =
@ -146,6 +153,7 @@ method contactNicknameChanged*(self: Module, publicKey: string) =
self.view.myMutualContactsModel().updateName(publicKey, name) self.view.myMutualContactsModel().updateName(publicKey, name)
self.view.receivedContactRequestsModel().updateName(publicKey, name) self.view.receivedContactRequestsModel().updateName(publicKey, name)
self.view.sentContactRequestsModel().updateName(publicKey, name) self.view.sentContactRequestsModel().updateName(publicKey, name)
self.view.receivedButRejectedContactRequestsModel().updateName(publicKey, name) # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
self.view.sentButRejectedContactRequestsModel().updateName(publicKey, name) # self.view.receivedButRejectedContactRequestsModel().updateName(publicKey, name)
# self.view.sentButRejectedContactRequestsModel().updateName(publicKey, name)
self.view.blockedContactsModel().updateName(publicKey, name) self.view.blockedContactsModel().updateName(publicKey, name)

View File

@ -15,10 +15,11 @@ QtObject:
receivedContactRequestsModelVariant: QVariant receivedContactRequestsModelVariant: QVariant
sentContactRequestsModel: Model sentContactRequestsModel: Model
sentContactRequestsModelVariant: QVariant sentContactRequestsModelVariant: QVariant
receivedButRejectedContactRequestsModel: Model # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
receivedButRejectedContactRequestsModelVariant: QVariant # receivedButRejectedContactRequestsModel: Model
sentButRejectedContactRequestsModel: Model # receivedButRejectedContactRequestsModelVariant: QVariant
sentButRejectedContactRequestsModelVariant: QVariant # sentButRejectedContactRequestsModel: Model
# sentButRejectedContactRequestsModelVariant: QVariant
proc delete*(self: View) = proc delete*(self: View) =
self.myMutualContactsModel.delete self.myMutualContactsModel.delete
@ -29,10 +30,11 @@ QtObject:
self.receivedContactRequestsModelVariant.delete self.receivedContactRequestsModelVariant.delete
self.sentContactRequestsModel.delete self.sentContactRequestsModel.delete
self.sentContactRequestsModelVariant.delete self.sentContactRequestsModelVariant.delete
self.receivedButRejectedContactRequestsModel.delete # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
self.receivedButRejectedContactRequestsModelVariant.delete # self.receivedButRejectedContactRequestsModel.delete
self.sentButRejectedContactRequestsModel.delete # self.receivedButRejectedContactRequestsModelVariant.delete
self.sentButRejectedContactRequestsModelVariant.delete # self.sentButRejectedContactRequestsModel.delete
# self.sentButRejectedContactRequestsModelVariant.delete
self.QObject.delete self.QObject.delete
proc newView*(delegate: io_interface.AccessInterface): View = proc newView*(delegate: io_interface.AccessInterface): View =
@ -47,10 +49,11 @@ QtObject:
result.receivedContactRequestsModelVariant = newQVariant(result.receivedContactRequestsModel) result.receivedContactRequestsModelVariant = newQVariant(result.receivedContactRequestsModel)
result.sentContactRequestsModel = newModel() result.sentContactRequestsModel = newModel()
result.sentContactRequestsModelVariant = newQVariant(result.sentContactRequestsModel) result.sentContactRequestsModelVariant = newQVariant(result.sentContactRequestsModel)
result.receivedButRejectedContactRequestsModel = newModel() # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
result.receivedButRejectedContactRequestsModelVariant = newQVariant(result.receivedButRejectedContactRequestsModel) # result.receivedButRejectedContactRequestsModel = newModel()
result.sentButRejectedContactRequestsModel = newModel() # result.receivedButRejectedContactRequestsModelVariant = newQVariant(result.receivedButRejectedContactRequestsModel)
result.sentButRejectedContactRequestsModelVariant = newQVariant(result.sentButRejectedContactRequestsModel) # result.sentButRejectedContactRequestsModel = newModel()
# result.sentButRejectedContactRequestsModelVariant = newQVariant(result.sentButRejectedContactRequestsModel)
proc load*(self: View) = proc load*(self: View) =
self.delegate.viewDidLoad() self.delegate.viewDidLoad()
@ -67,11 +70,12 @@ QtObject:
proc sentContactRequestsModel*(self: View): Model = proc sentContactRequestsModel*(self: View): Model =
return self.sentContactRequestsModel return self.sentContactRequestsModel
proc receivedButRejectedContactRequestsModel*(self: View): Model = # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
return self.receivedButRejectedContactRequestsModel # proc receivedButRejectedContactRequestsModel*(self: View): Model =
# return self.receivedButRejectedContactRequestsModel
proc sentButRejectedContactRequestsModel*(self: View): Model = # proc sentButRejectedContactRequestsModel*(self: View): Model =
return self.sentButRejectedContactRequestsModel # return self.sentButRejectedContactRequestsModel
proc myMutualContactsModelChanged(self: View) {.signal.} proc myMutualContactsModelChanged(self: View) {.signal.}
proc getMyMutualContactsModel(self: View): QVariant {.slot.} = proc getMyMutualContactsModel(self: View): QVariant {.slot.} =
@ -101,19 +105,20 @@ QtObject:
read = getSentContactRequestsModel read = getSentContactRequestsModel
notify = sentContactRequestsModelChanged notify = sentContactRequestsModelChanged
proc receivedButRejectedContactRequestsModelChanged(self: View) {.signal.} # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
proc getReceivedButRejectedContactRequestsModel(self: View): QVariant {.slot.} = # proc receivedButRejectedContactRequestsModelChanged(self: View) {.signal.}
return self.receivedButRejectedContactRequestsModelVariant # proc getReceivedButRejectedContactRequestsModel(self: View): QVariant {.slot.} =
QtProperty[QVariant] receivedButRejectedContactRequestsModel: # return self.receivedButRejectedContactRequestsModelVariant
read = getReceivedButRejectedContactRequestsModel # QtProperty[QVariant] receivedButRejectedContactRequestsModel:
notify = receivedButRejectedContactRequestsModelChanged # read = getReceivedButRejectedContactRequestsModel
# notify = receivedButRejectedContactRequestsModelChanged
proc sentButRejectedContactRequestsModelChanged(self: View) {.signal.} # proc sentButRejectedContactRequestsModelChanged(self: View) {.signal.}
proc getSentButRejectedContactRequestsModel(self: View): QVariant {.slot.} = # proc getSentButRejectedContactRequestsModel(self: View): QVariant {.slot.} =
return self.sentButRejectedContactRequestsModelVariant # return self.sentButRejectedContactRequestsModelVariant
QtProperty[QVariant] sentButRejectedContactRequestsModel: # QtProperty[QVariant] sentButRejectedContactRequestsModel:
read = getSentButRejectedContactRequestsModel # read = getSentButRejectedContactRequestsModel
notify = sentButRejectedContactRequestsModelChanged # notify = sentButRejectedContactRequestsModelChanged
proc isMyMutualContact*(self: View, publicKey: string): bool {.slot.} = proc isMyMutualContact*(self: View, publicKey: string): bool {.slot.} =
return self.myMutualContactsModel.containsItemWithPubKey(publicKey) return self.myMutualContactsModel.containsItemWithPubKey(publicKey)

View File

@ -100,15 +100,20 @@ proc isContactRequestReceived*(self: ContactsDto): bool =
proc isContactRequestSent*(self: ContactsDto): bool = proc isContactRequestSent*(self: ContactsDto): bool =
return self.added return self.added
proc isSentContactRequestRejected*(self: ContactsDto): bool = proc isContactRemoved*(self: ContactsDto): bool =
# TODO not implemented in `status-go` yet
# We don't have this prop for now.
return false
proc isReceivedContactRequestRejected*(self: ContactsDto): bool =
# We need to check this.
return self.removed return self.removed
# Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
# proc isSentContactRequestRejected*(self: ContactsDto): bool =
# # TODO not implemented in `status-go` yet
# # We don't have this prop for now.
# return false
# Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
# proc isReceivedContactRequestRejected*(self: ContactsDto): bool =
# # We need to check this.
# return self.removed
proc isBlocked*(self: ContactsDto): bool = proc isBlocked*(self: ContactsDto): bool =
return self.blocked return self.blocked

View File

@ -170,24 +170,27 @@ QtObject:
return contacts.filter(x => x.id != myPubKey and return contacts.filter(x => x.id != myPubKey and
x.isContactRequestReceived() and x.isContactRequestReceived() and
not x.isContactRequestSent() and not x.isContactRequestSent() and
not x.isReceivedContactRequestRejected() and not x.isContactRemoved() and
# not x.isReceivedContactRequestRejected() and
not x.isBlocked()) not x.isBlocked())
elif (group == ContactsGroup.OutgoingPendingContactRequests): elif (group == ContactsGroup.OutgoingPendingContactRequests):
return contacts.filter(x => x.id != myPubKey and return contacts.filter(x => x.id != myPubKey and
x.isContactRequestSent() and x.isContactRequestSent() and
not x.isContactRequestReceived() and not x.isContactRequestReceived() and
not x.isSentContactRequestRejected() and # not x.isSentContactRequestRejected() and
not x.isBlocked()) not x.isContactRemoved() and
elif (group == ContactsGroup.IncomingRejectedContactRequests):
return contacts.filter(x => x.id != myPubKey and
x.isContactRequestReceived() and
x.isReceivedContactRequestRejected() and
not x.isBlocked())
elif (group == ContactsGroup.OutgoingRejectedContactRequests):
return contacts.filter(x => x.id != myPubKey and
x.isContactRequestSent() and
x.isSentContactRequestRejected() and
not x.isBlocked()) not x.isBlocked())
# Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
# elif (group == ContactsGroup.IncomingRejectedContactRequests):
# return contacts.filter(x => x.id != myPubKey and
# x.isContactRequestReceived() and
# x.isReceivedContactRequestRejected() and
# not x.isBlocked())
# elif (group == ContactsGroup.OutgoingRejectedContactRequests):
# return contacts.filter(x => x.id != myPubKey and
# x.isContactRequestSent() and
# x.isSentContactRequestRejected() and
# not x.isBlocked())
elif (group == ContactsGroup.BlockedContacts): elif (group == ContactsGroup.BlockedContacts):
return contacts.filter(x => x.id != myPubKey and return contacts.filter(x => x.id != myPubKey and
x.isBlocked()) x.isBlocked())
@ -195,6 +198,7 @@ QtObject:
# we need to revise this when we introduce "identity verification" feature # we need to revise this when we introduce "identity verification" feature
return contacts.filter(x => x.id != myPubKey and return contacts.filter(x => x.id != myPubKey and
x.isMutualContact() and x.isMutualContact() and
not x.isContactRemoved() and
not x.isBlocked()) not x.isBlocked())
elif (group == ContactsGroup.AllKnownContacts): elif (group == ContactsGroup.AllKnownContacts):
return contacts return contacts

View File

@ -151,8 +151,11 @@ QtObject:
error "error: received `chats` array for handling messages update is empty" error "error: received `chats` array for handling messages update is empty"
return return
if (not chats[0].active): # Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
return # blocking contact deletes the chat on the `status-go` side, after unblocking it, `active` prop is still false
# that's the reason why the following check is commented out here.
# if (not chats[0].active):
# return
let chatId = chats[0].id let chatId = chats[0].id
let chatType = chats[0].chatType let chatType = chats[0].chatType

View File

@ -13,7 +13,7 @@ proc getContactById*(id: string): RpcResponse[JsonNode] {.raises: [Exception].}
result = callPrivateRPC("getContactByID".prefix, payload) result = callPrivateRPC("getContactByID".prefix, payload)
proc blockContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} = proc blockContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("blockContact".prefix, %* [id]) result = callPrivateRPC("blockContactDesktop".prefix, %* [id])
proc unblockContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} = proc unblockContact*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
result = callPrivateRPC("unblockContact".prefix, %* [id]) result = callPrivateRPC("unblockContact".prefix, %* [id])

View File

@ -15,8 +15,10 @@ QtObject {
property var blockedContactsModel: contactsModule.blockedContactsModel property var blockedContactsModel: contactsModule.blockedContactsModel
property var receivedContactRequestsModel: contactsModule.receivedContactRequestsModel property var receivedContactRequestsModel: contactsModule.receivedContactRequestsModel
property var sentContactRequestsModel: contactsModule.sentContactRequestsModel property var sentContactRequestsModel: contactsModule.sentContactRequestsModel
property var receivedButRejectedContactRequestsModel: contactsModule.receivedButRejectedContactRequestsModel
property var sentButRejectedContactRequestsModel: contactsModule.sentButRejectedContactRequestsModel // Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
// property var receivedButRejectedContactRequestsModel: contactsModule.receivedButRejectedContactRequestsModel
// property var sentButRejectedContactRequestsModel: contactsModule.sentButRejectedContactRequestsModel
function resolveENS(value) { function resolveENS(value) {
root.mainModuleInst.resolveENS(value, "") root.mainModuleInst.resolveENS(value, "")

View File

@ -106,13 +106,14 @@ Item {
btnText: qsTr("Pending Requests") btnText: qsTr("Pending Requests")
badge.value: contactList.count badge.value: contactList.count
} }
StatusTabButton { // Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
id: rejectedRequestsBtn // StatusTabButton {
addToWidth: Style.current.bigPadding // id: rejectedRequestsBtn
enabled: root.contactsStore.receivedButRejectedContactRequestsModel.count > 0 || // addToWidth: Style.current.bigPadding
root.contactsStore.sentButRejectedContactRequestsModel.count > 0 // enabled: root.contactsStore.receivedButRejectedContactRequestsModel.count > 0 ||
btnText: qsTr("Rejected Requests") // root.contactsStore.sentButRejectedContactRequestsModel.count > 0
} // btnText: qsTr("Rejected Requests")
// }
StatusTabButton { StatusTabButton {
id: blockedBtn id: blockedBtn
addToWidth: Style.current.bigPadding addToWidth: Style.current.bigPadding
@ -255,60 +256,61 @@ Item {
} }
} }
// REJECTED REQUESTS // Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
Item { // // REJECTED REQUESTS
Layout.fillWidth: true // Item {
Layout.fillHeight: true // Layout.fillWidth: true
// Layout.fillHeight: true
ColumnLayout { // ColumnLayout {
anchors.fill: parent // anchors.fill: parent
ContactsListPanel { // ContactsListPanel {
Layout.fillWidth: true // Layout.fillWidth: true
Layout.preferredHeight: parent.height * 0.5 // Layout.preferredHeight: parent.height * 0.5
clip: true // clip: true
title: qsTr("Received") // title: qsTr("Received")
searchString: searchBox.text // searchString: searchBox.text
contactsModel: root.contactsStore.receivedButRejectedContactRequestsModel // contactsModel: root.contactsStore.receivedButRejectedContactRequestsModel
panelUsage: Constants.contactsPanelUsage.rejectedReceivedContactRequest // panelUsage: Constants.contactsPanelUsage.rejectedReceivedContactRequest
onOpenProfilePopup: { // onOpenProfilePopup: {
Global.openProfilePopup(publicKey) // Global.openProfilePopup(publicKey)
} // }
onOpenChangeNicknamePopup: { // onOpenChangeNicknamePopup: {
Global.openProfilePopup(publicKey, null, true) // Global.openProfilePopup(publicKey, null, true)
} // }
onRejectionRemoved: { // onRejectionRemoved: {
root.contactsStore.removeContactRequestRejection(publicKey) // root.contactsStore.removeContactRequestRejection(publicKey)
} // }
} // }
ContactsListPanel { // ContactsListPanel {
Layout.fillWidth: true // Layout.fillWidth: true
Layout.preferredHeight: parent.height * 0.5 // Layout.preferredHeight: parent.height * 0.5
clip: true // clip: true
title: qsTr("Sent") // title: qsTr("Sent")
searchString: searchBox.text // searchString: searchBox.text
contactsModel: root.contactsStore.sentButRejectedContactRequestsModel // contactsModel: root.contactsStore.sentButRejectedContactRequestsModel
panelUsage: Constants.contactsPanelUsage.rejectedSentContactRequest // panelUsage: Constants.contactsPanelUsage.rejectedSentContactRequest
onOpenProfilePopup: { // onOpenProfilePopup: {
Global.openProfilePopup(publicKey) // Global.openProfilePopup(publicKey)
} // }
onOpenChangeNicknamePopup: { // onOpenChangeNicknamePopup: {
Global.openProfilePopup(publicKey, null, true) // Global.openProfilePopup(publicKey, null, true)
} // }
} // }
Item { // Item {
Layout.fillWidth: true // Layout.fillWidth: true
Layout.fillHeight: true // Layout.fillHeight: true
} // }
} // }
} // }
// BLOCKED // BLOCKED
ContactsListPanel { ContactsListPanel {

@ -1 +1 @@
Subproject commit 34acdba156be8faf7ea9bacaa86eed41863fe88c Subproject commit 06d52222add28c4d65e3a8816881f1c843cd0787