feat(Chat): Disable sending messages for non contacts

Close #9899
This commit is contained in:
MishkaRogachev 2023-03-15 13:30:18 +05:30 committed by Jonathan Rainville
parent b45cc15e32
commit ad4838e4f8
3 changed files with 22 additions and 2 deletions

View File

@ -40,7 +40,7 @@ Item {
property int chatsCount: parentModule && parentModule.model ? parentModule.model.count : 0
property int activeChatType: parentModule && parentModule.activeItem.type
property bool stickersLoaded: false
property var contactDetails: activeChatType === Constants.chatType.oneToOne && Utils.getContactDetailsAsJson(root.activeChatId, false)
property var contactDetails: null
property bool isUserAdded: root.contactDetails && root.contactDetails.isAdded
signal openAppSearch()
@ -107,6 +107,21 @@ Item {
root.rootStore.createChatStickerPackId = "";
}
function updateContactDetails() {
contactDetails = activeChatType === Constants.chatType.oneToOne && Utils.getContactDetailsAsJson(root.activeChatId, false)
}
onActiveChatIdChanged: root.updateContactDetails()
Connections {
target: root.contactsStore.myContactsModel
function onItemChanged(pubKey) {
if (pubKey === root.activeChatId)
root.updateContactDetails()
}
}
EmptyChatPanel {
anchors.fill: parent
visible: root.activeChatId === "" || root.chatsCount == 0
@ -140,6 +155,7 @@ Item {
sendTransactionWithEnsModal: cmpSendTransactionWithEns
stickersLoaded: root.stickersLoaded
isBlocked: model.blocked
isUserAdded: root.isUserAdded
isActiveChannel: chatLoader.visible
onOpenStickerPackPopup: {
root.openStickerPackPopup(stickerPackId)

View File

@ -53,6 +53,7 @@ ColumnLayout {
property Component sendTransactionWithEnsModal
property bool isBlocked: false
property bool isUserAdded: false
property bool stickersLoaded: false
@ -176,7 +177,8 @@ ColumnLayout {
anchors.fill: parent
anchors.margins: Style.current.smallPadding
enabled: root.activeSectionData.joined && !root.activeSectionData.amIBanned
enabled: root.activeSectionData.joined && !root.activeSectionData.amIBanned &&
!(chatType === Constants.chatType.oneToOne && !root.isUserAdded)
store: root.rootStore
usersStore: root.usersStore

View File

@ -1337,6 +1337,8 @@ Rectangle {
}
}
onEnabledChanged: if (!enabled) text = ""
cursorDelegate: Rectangle {
color: Theme.palette.primaryColor1
implicitWidth: 2