feat(Chat): Accept/Reject CR buttons for 1-to-1 chat

This commit is contained in:
MishkaRogachev 2023-04-26 13:20:17 +04:00 committed by Jonathan Rainville
parent 6ba6a5fcde
commit 7b31929f85
2 changed files with 21 additions and 9 deletions

View File

@ -1,6 +1,7 @@
import QtQuick 2.15 import QtQuick 2.15
import QtQml 2.15 import QtQml 2.15
import QtQuick.Controls 2.15 import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1 as StatusQUtils import StatusQ.Core.Utils 0.1 as StatusQUtils
@ -124,7 +125,7 @@ ColumnLayout {
sourceComponent: MessageContextMenuView { sourceComponent: MessageContextMenuView {
store: root.rootStore store: root.rootStore
reactionModel: root.rootStore.emojiReactionsModel reactionModel: root.rootStore.emojiReactionsModel
disabledForChat: chatType === Constants.chatType.oneToOne && d.contactRequestState !== Constants.ContactRequestState.Mutual disabledForChat: root.chatType === Constants.chatType.oneToOne && root.contactRequestState !== Constants.ContactRequestState.Mutual
onPinMessage: { onPinMessage: {
messageStore.pinMessage(messageId) messageStore.pinMessage(messageId)
@ -248,7 +249,7 @@ ColumnLayout {
anchors.margins: Style.current.smallPadding anchors.margins: Style.current.smallPadding
enabled: root.rootStore.sectionDetails.joined && !root.rootStore.sectionDetails.amIBanned && enabled: root.rootStore.sectionDetails.joined && !root.rootStore.sectionDetails.amIBanned &&
!(chatType === Constants.chatType.oneToOne && d.contactRequestState !== Constants.ContactRequestState.Mutual) !(chatType === Constants.chatType.oneToOne && root.contactRequestState !== Constants.ContactRequestState.Mutual)
store: root.rootStore store: root.rootStore
usersStore: root.usersStore usersStore: root.usersStore

View File

@ -253,7 +253,7 @@ Item {
chatLogView: ListView.view chatLogView: ListView.view
isActiveChannel: root.isActiveChannel isActiveChannel: root.isActiveChannel
isChatBlocked: root.isChatBlocked || (root.isOneToOne && d.contactRequestState !== Constants.ContactRequestState.Mutual) isChatBlocked: root.isChatBlocked || (root.isOneToOne && root.contactRequestState !== Constants.ContactRequestState.Mutual)
messageContextMenu: root.messageContextMenu messageContextMenu: root.messageContextMenu
messageId: model.id messageId: model.id
@ -339,7 +339,7 @@ Item {
case Constants.ContactRequestState.Dismissed: case Constants.ContactRequestState.Dismissed:
return sendContactRequestComponent return sendContactRequestComponent
case Constants.ContactRequestState.Received: case Constants.ContactRequestState.Received:
return acceptContactRequestComponent return acceptOrDeclineContactRequestComponent
case Constants.ContactRequestState.Sent: case Constants.ContactRequestState.Sent:
return pendingContactRequestComponent return pendingContactRequestComponent
default: default:
@ -371,13 +371,24 @@ Item {
} }
Component { Component {
id: acceptContactRequestComponent id: acceptOrDeclineContactRequestComponent
StatusButton { RowLayout {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Accept Contact Request")
onClicked: { StatusButton {
root.contactsStore.acceptContactRequest(root.publicKey, "") text: qsTr("Reject Contact Request")
type: StatusBaseButton.Type.Danger
onClicked: {
root.contactsStore.dismissContactRequest(root.publicKey, "")
}
}
StatusButton {
text: qsTr("Accept Contact Request")
onClicked: {
root.contactsStore.acceptContactRequest(root.publicKey, "")
}
} }
} }
} }