From 7b95031ee6349c4aa537d7c893cb76e30aaee0f9 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 26 May 2021 14:56:04 -0400 Subject: [PATCH] hide input field until mutual contacts and notify on contact accepted --- src/app/profile/views/contacts.nim | 7 ++++--- ui/app/AppLayouts/Chat/ChatColumn.qml | 8 ++++++-- .../ChatColumn/ChatComponents/ChatRequestMessage.qml | 9 ++++++--- ui/app/AppLayouts/Chat/ContactsColumn.qml | 7 +++++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/app/profile/views/contacts.nim b/src/app/profile/views/contacts.nim index d02ed363db..dd12d2090d 100644 --- a/src/app/profile/views/contacts.nim +++ b/src/app/profile/views/contacts.nim @@ -63,6 +63,8 @@ QtObject: ) result.setup + proc contactListChanged*(self: ContactsView) {.signal.} + proc updateContactList*(self: ContactsView, contacts: seq[Profile]) = for contact in contacts: self.contactList.updateContact(contact) @@ -72,8 +74,7 @@ QtObject: self.blockedContacts.updateContact(contact) if contact.systemTags.contains(contactRequest) and not contact.systemTags.contains(contactAdded) and not contact.systemTags.contains(contactBlocked): self.contactRequests.updateContact(contact) - - proc contactListChanged*(self: ContactsView) {.signal.} + self.contactListChanged() proc getContactList(self: ContactsView): QVariant {.slot.} = return newQVariant(self.contactList) @@ -89,7 +90,7 @@ QtObject: proc notifyOnNewContactRequests*(self: ContactsView, contacts: seq[Profile]) = for contact in contacts: - if contact.systemTags.contains(contactRequest) and not contact.systemTags.contains(contactAdded) and not contact.systemTags.contains(contactBlocked): + if contact.systemTags.contains(contactRequest) and not contact.systemTags.contains(contactBlocked): self.contactRequestAdded(status_ens.userNameOrAlias(contact), contact.address) QtProperty[QVariant] list: diff --git a/ui/app/AppLayouts/Chat/ChatColumn.qml b/ui/app/AppLayouts/Chat/ChatColumn.qml index e291bb7fd2..b94fbee0a3 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn.qml @@ -35,6 +35,7 @@ StackLayout { property string activeChatId: chatsModel.activeChannel.id property bool isBlocked: profileModel.contacts.isContactBlocked(activeChatId) property bool isContact: profileModel.contacts.isAdded(activeChatId) + property bool contactRequestReceived: profileModel.contacts.contactRequestReceived(activeChatId) property string currentNotificationChatId property string currentNotificationCommunityId @@ -343,10 +344,13 @@ StackLayout { StatusChatInput { id: chatInput visible: { - const community = chatsModel.communities.activeCommunity if (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat) { return chatsModel.activeChannel.isMember } + if (chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne) { + return isContact && contactRequestReceived + } + const community = chatsModel.communities.activeCommunity return !community.active || community.access === Constants.communityChatPublicAccess || community.admin || @@ -497,4 +501,4 @@ StackLayout { Designer { D{i:0;formeditorColor:"#ffffff";height:770;width:800} } -##^##*/ \ No newline at end of file +##^##*/ diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatRequestMessage.qml b/ui/app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatRequestMessage.qml index a5b9219df0..8548293938 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatRequestMessage.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ChatComponents/ChatRequestMessage.qml @@ -4,7 +4,7 @@ import "../../../../../shared" import "../../../../../shared/status" Item { - visible: chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne && !isContact + visible: chatsModel.activeChannel.chatType === Constants.chatTypeOneToOne && (!isContact || !contactRequestReceived) width: parent.width height: childrenRect.height @@ -18,7 +18,8 @@ Item { StyledText { id: contactText1 - text: qsTr("You need to be mutual contacts with this person for them to receive your messages") + text: !isContact ? qsTr("You need to be mutual contacts with this person for them to receive your messages") : + qsTr("Waiting for %1 to accept your request").arg(Utils.removeStatusEns(chatsModel.activeChannel.name)) anchors.top: waveImg.bottom horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap @@ -29,7 +30,8 @@ Item { StyledText { id: contactText2 - text: qsTr("Just click this button to add them as contact. They will receive a notification all once they accept you as contact as well, you'll be able to chat") + visible: !isContact + text: qsTr("Just click this button to add them as contact. They will receive a notification. Once they accept the request, you'll be able to chat") horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap anchors.top: contactText1.bottom @@ -39,6 +41,7 @@ Item { } StatusButton { + visible: !isContact text: qsTr("Add to contacts") anchors.top: contactText2.bottom anchors.topMargin: Style.current.smallPadding diff --git a/ui/app/AppLayouts/Chat/ContactsColumn.qml b/ui/app/AppLayouts/Chat/ContactsColumn.qml index 610ed84bfe..9eaaa60691 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn.qml @@ -125,8 +125,11 @@ Rectangle { if (!appSettings.notifyOnNewRequests) { return } - systemTray.showMessage(qsTr("New contact request"), - qsTr("%1 requests to become contacts").arg(Utils.removeStatusEns(name)), + const isContact = profileModel.contacts.isAdded(address) + systemTray.showMessage(isContact ? qsTr("Contact request accepted") : + qsTr("New contact request"), + isContact ? qsTr("You can now chat with %1").arg(Utils.removeStatusEns(name)) : + qsTr("%1 requests to become contacts").arg(Utils.removeStatusEns(name)), SystemTrayIcon.NoIcon, Constants.notificationPopupTTL) }