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

View File

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

View File

@ -100,15 +100,20 @@ proc isContactRequestReceived*(self: ContactsDto): bool =
proc isContactRequestSent*(self: ContactsDto): bool =
return self.added
proc isSentContactRequestRejected*(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.
proc isContactRemoved*(self: ContactsDto): bool =
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 =
return self.blocked

View File

@ -170,24 +170,27 @@ QtObject:
return contacts.filter(x => x.id != myPubKey and
x.isContactRequestReceived() and
not x.isContactRequestSent() and
not x.isReceivedContactRequestRejected() and
not x.isContactRemoved() and
# not x.isReceivedContactRequestRejected() and
not x.isBlocked())
elif (group == ContactsGroup.OutgoingPendingContactRequests):
return contacts.filter(x => x.id != myPubKey and
x.isContactRequestSent() and
not x.isContactRequestReceived() and
not x.isSentContactRequestRejected() and
not x.isBlocked())
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.isSentContactRequestRejected() and
not x.isContactRemoved() and
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):
return contacts.filter(x => x.id != myPubKey and
x.isBlocked())
@ -195,6 +198,7 @@ QtObject:
# we need to revise this when we introduce "identity verification" feature
return contacts.filter(x => x.id != myPubKey and
x.isMutualContact() and
not x.isContactRemoved() and
not x.isBlocked())
elif (group == ContactsGroup.AllKnownContacts):
return contacts

View File

@ -151,8 +151,11 @@ QtObject:
error "error: received `chats` array for handling messages update is empty"
return
if (not chats[0].active):
return
# Temporary commented until we provide appropriate flags on the `status-go` side to cover all sections.
# 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 chatType = chats[0].chatType

View File

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

View File

@ -15,8 +15,10 @@ QtObject {
property var blockedContactsModel: contactsModule.blockedContactsModel
property var receivedContactRequestsModel: contactsModule.receivedContactRequestsModel
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) {
root.mainModuleInst.resolveENS(value, "")

View File

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

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