fix(@desktop/chat): contact lists should only shown mutual contacts

Fixes #5117
This commit is contained in:
Sale Djenic 2022-03-25 12:33:30 +01:00 committed by saledjenic
parent 149ff69310
commit 57fb0882aa
7 changed files with 24 additions and 18 deletions

View File

@ -115,6 +115,9 @@ QtObject:
read = getSentButRejectedContactRequestsModel read = getSentButRejectedContactRequestsModel
notify = sentButRejectedContactRequestsModelChanged notify = sentButRejectedContactRequestsModelChanged
proc isMyMutualContact*(self: View, publicKey: string): bool {.slot.} =
return self.myMutualContactsModel.containsItemWithPubKey(publicKey)
proc addContact*(self: View, publicKey: string) {.slot.} = proc addContact*(self: View, publicKey: string) {.slot.} =
self.delegate.addContact(publicKey) self.delegate.addContact(publicKey)

View File

@ -16,7 +16,7 @@ QtObject {
property string createChatStickerHashId: "" property string createChatStickerHashId: ""
property string createChatStickerPackId: "" property string createChatStickerPackId: ""
property var contactsModel: profileSectionModule.contactsModule.myContactsModel property var contactsModel: root.contactsStore.myContactsModel
// Important: // Important:
// Each `ChatLayout` has its own chatCommunitySectionModule // Each `ChatLayout` has its own chatCommunitySectionModule

View File

@ -43,9 +43,9 @@ StatusListItem {
signal openProfilePopup(string publicKey) signal openProfilePopup(string publicKey)
signal openChangeNicknamePopup(string publicKey) signal openChangeNicknamePopup(string publicKey)
signal sendMessageActionTriggered(string publicKey) signal sendMessageActionTriggered(string publicKey)
signal acceptContactRequest(string publicKey) signal contactRequestAccepted(string publicKey)
signal rejectContactRequest(string publicKey) signal contactRequestRejected(string publicKey)
signal removeRejection(string publicKey) signal rejectionRemoved(string publicKey)
signal textClicked(string publicKey) signal textClicked(string publicKey)
components: [ components: [
@ -63,7 +63,7 @@ StatusListItem {
height: visible ? 32 : 0 height: visible ? 32 : 0
icon.name: "close-circle" icon.name: "close-circle"
icon.color: Style.current.danger icon.color: Style.current.danger
onClicked: container.rejectContactRequest(container.publicKey) onClicked: container.contactRequestRejected(container.publicKey)
}, },
StatusFlatRoundButton { StatusFlatRoundButton {
visible: showAcceptContactRequestButton visible: showAcceptContactRequestButton
@ -71,7 +71,7 @@ StatusListItem {
height: visible ? 32 : 0 height: visible ? 32 : 0
icon.name: "checkmark-circle" icon.name: "checkmark-circle"
icon.color: Style.current.success icon.color: Style.current.success
onClicked: container.acceptContactRequest(container.publicKey) onClicked: container.contactRequestAccepted(container.publicKey)
}, },
StatusFlatRoundButton { StatusFlatRoundButton {
visible: showRemoveRejectionButton visible: showRemoveRejectionButton
@ -79,7 +79,7 @@ StatusListItem {
height: visible ? 32 : 0 height: visible ? 32 : 0
icon.name: "cancel" icon.name: "cancel"
icon.color: Style.current.danger icon.color: Style.current.danger
onClicked: container.removeRejection(container.publicKey) onClicked: container.rejectionRemoved(container.publicKey)
}, },
StatusBaseText { StatusBaseText {
text: container.contactText text: container.contactText

View File

@ -25,9 +25,9 @@ Item {
signal openProfilePopup(string publicKey) signal openProfilePopup(string publicKey)
signal sendMessageActionTriggered(string publicKey) signal sendMessageActionTriggered(string publicKey)
signal openChangeNicknamePopup(string publicKey) signal openChangeNicknamePopup(string publicKey)
signal acceptContactRequest(string publicKey) signal contactRequestAccepted(string publicKey)
signal rejectContactRequest(string publicKey) signal contactRequestRejected(string publicKey)
signal removeRejection(string publicKey) signal rejectionRemoved(string publicKey)
signal textClicked(string publicKey) signal textClicked(string publicKey)
visible: contactsList.count > 0 visible: contactsList.count > 0
@ -150,9 +150,9 @@ Item {
onOpenProfilePopup: contactListRoot.openProfilePopup(publicKey) onOpenProfilePopup: contactListRoot.openProfilePopup(publicKey)
onSendMessageActionTriggered: contactListRoot.sendMessageActionTriggered(publicKey) onSendMessageActionTriggered: contactListRoot.sendMessageActionTriggered(publicKey)
onOpenChangeNicknamePopup: contactListRoot.openChangeNicknamePopup(publicKey) onOpenChangeNicknamePopup: contactListRoot.openChangeNicknamePopup(publicKey)
onAcceptContactRequest: contactListRoot.acceptContactRequest(publicKey) onContactRequestAccepted: contactListRoot.contactRequestAccepted(publicKey)
onRejectContactRequest: contactListRoot.rejectContactRequest(publicKey) onContactRequestRejected: contactListRoot.contactRequestRejected(publicKey)
onRemoveRejection: contactListRoot.removeRejection(publicKey) onRejectionRemoved: contactListRoot.rejectionRemoved(publicKey)
onTextClicked: contactListRoot.textClicked(publicKey) onTextClicked: contactListRoot.textClicked(publicKey)
visible: searchString === "" || visible: searchString === "" ||

View File

@ -30,6 +30,10 @@ QtObject {
return root.globalUtilsInst.getFromClipboard() return root.globalUtilsInst.getFromClipboard()
} }
function isMyMutualContact(pubKey) {
return root.contactsModule.isMyMutualContact(pubKey)
}
function joinPrivateChat(pubKey) { function joinPrivateChat(pubKey) {
Global.changeAppSectionBySectionType(Constants.appSection.chat) Global.changeAppSectionBySectionType(Constants.appSection.chat)
root.contactsModule.addContact(pubKey) root.contactsModule.addContact(pubKey)

View File

@ -221,11 +221,11 @@ Item {
Global.openProfilePopup(publicKey, null, true) Global.openProfilePopup(publicKey, null, true)
} }
onAcceptContactRequest: { onContactRequestAccepted: {
root.contactsStore.acceptContactRequest(publicKey) root.contactsStore.acceptContactRequest(publicKey)
} }
onRejectContactRequest: { onContactRequestRejected: {
root.contactsStore.rejectContactRequest(publicKey) root.contactsStore.rejectContactRequest(publicKey)
} }
} }
@ -280,7 +280,7 @@ Item {
Global.openProfilePopup(publicKey, null, true) Global.openProfilePopup(publicKey, null, true)
} }
onRemoveRejection: { onRejectionRemoved: {
root.contactsStore.removeContactRequestRejection(publicKey) root.contactsStore.removeContactRequestRejection(publicKey)
} }
} }

View File

@ -188,8 +188,7 @@ StatusPopupMenu {
root.close() root.close()
} }
icon.name: "chat" icon.name: "chat"
enabled: (root.myPublicKey !== root.selectedUserPublicKey) && enabled: root.isProfile && root.store.contactsStore.isMyMutualContact(root.selectedUserPublicKey) ||
root.isProfile && !root.isMyMessage ||
(!root.hideEmojiPicker && (!root.hideEmojiPicker &&
!root.emojiOnly && !root.emojiOnly &&
!root.isProfile && !root.isProfile &&