2024-02-26 18:54:05 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQml.Models 2.15
|
2022-06-28 18:11:18 +00:00
|
|
|
|
2023-08-18 11:12:46 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2022-06-28 18:11:18 +00:00
|
|
|
import StatusQ.Core 0.1
|
2024-02-26 18:54:05 +00:00
|
|
|
import StatusQ.Components 0.1
|
2022-06-28 18:11:18 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-08-18 11:12:46 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2022-06-28 18:11:18 +00:00
|
|
|
|
2023-01-12 12:37:37 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Profile.stores 1.0 as ProfileStores
|
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
CommonContactDialog {
|
2022-06-28 18:11:18 +00:00
|
|
|
id: root
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
required property ProfileStores.ContactsStore contactsStore
|
2022-06-28 18:11:18 +00:00
|
|
|
|
|
|
|
signal verificationRefused(string senderPublicKey)
|
|
|
|
signal responseSent(string senderPublicKey, string response)
|
|
|
|
|
2022-12-09 12:33:20 +00:00
|
|
|
function updateVerificationDetails() {
|
2022-12-02 13:02:41 +00:00
|
|
|
try {
|
|
|
|
const request = root.contactsStore.getVerificationDetailsFromAsJson(root.publicKey)
|
|
|
|
|
|
|
|
if (request.requestStatus === Constants.verificationStatus.canceled) {
|
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
|
2023-01-03 23:38:16 +00:00
|
|
|
d.senderPublicKey = request.from
|
2022-12-02 13:02:41 +00:00
|
|
|
d.challengeText = request.challenge
|
|
|
|
d.responseText = request.response
|
|
|
|
d.messageTimestamp = request.requestedAt
|
|
|
|
} catch (e) {
|
|
|
|
console.error("Error getting or parsing verification data", e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
readonly property var _con: Connections {
|
|
|
|
target: root.contactsStore.receivedContactRequestsModel ?? null
|
2022-12-09 12:33:20 +00:00
|
|
|
|
|
|
|
function onItemChanged(pubKey) {
|
|
|
|
if (pubKey === root.publicKey)
|
|
|
|
root.updateVerificationDetails()
|
2022-12-02 13:02:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
readonly property var d: QtObject {
|
2022-12-02 13:02:41 +00:00
|
|
|
id: d
|
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
property string senderPublicKey
|
|
|
|
property string challengeText
|
|
|
|
property string responseText
|
2023-02-17 10:25:48 +00:00
|
|
|
property double messageTimestamp
|
|
|
|
property double responseTimestamp
|
2022-12-02 13:02:41 +00:00
|
|
|
}
|
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
title: qsTr("Reply to ID verification request")
|
2022-06-28 18:11:18 +00:00
|
|
|
|
2023-02-17 10:25:48 +00:00
|
|
|
onAboutToShow: {
|
2022-12-09 12:33:20 +00:00
|
|
|
root.updateVerificationDetails()
|
2024-02-26 18:54:05 +00:00
|
|
|
verificationResponse.input.edit.forceActiveFocus()
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: msgColumn.implicitHeight + msgColumn.anchors.topMargin + msgColumn.anchors.bottomMargin
|
|
|
|
color: "transparent"
|
|
|
|
border.width: 1
|
|
|
|
border.color: Theme.palette.baseColor2
|
|
|
|
radius: Style.current.radius
|
2023-01-12 12:37:37 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
2024-02-26 18:54:05 +00:00
|
|
|
id: msgColumn
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: Style.current.padding
|
2023-01-12 12:37:37 +00:00
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
StatusTimeStampLabel {
|
2023-01-12 12:37:37 +00:00
|
|
|
Layout.fillWidth: true
|
2023-01-13 13:32:36 +00:00
|
|
|
timestamp: d.messageTimestamp
|
2023-01-12 12:37:37 +00:00
|
|
|
}
|
|
|
|
StatusBaseText {
|
|
|
|
Layout.fillWidth: true
|
2024-02-26 18:54:05 +00:00
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
text: d.challengeText
|
2023-01-12 12:37:37 +00:00
|
|
|
}
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-26 18:54:05 +00:00
|
|
|
StatusInput {
|
|
|
|
id: verificationResponse
|
|
|
|
input.multiline: true
|
|
|
|
label: qsTr("Your answer")
|
|
|
|
placeholderText: qsTr("Write your answer...")
|
|
|
|
minimumHeight: 152
|
|
|
|
maximumHeight: 152
|
|
|
|
input.verticalAlignment: TextEdit.AlignTop
|
|
|
|
charLimit: 280
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
rightButtons: ObjectModel {
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Decline")
|
|
|
|
type: StatusBaseButton.Type.Danger
|
|
|
|
objectName: "refuseVerificationButton"
|
|
|
|
onClicked: {
|
|
|
|
root.verificationRefused(d.senderPublicKey)
|
|
|
|
root.close()
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
2024-02-26 18:54:05 +00:00
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Send reply")
|
|
|
|
type: StatusBaseButton.Type.Success
|
|
|
|
objectName: "sendAnswerButton"
|
|
|
|
enabled: verificationResponse.text !== ""
|
|
|
|
onClicked: {
|
|
|
|
root.responseSent(d.senderPublicKey, SQUtils.StringUtils.escapeHtml(verificationResponse.text))
|
|
|
|
d.responseText = verificationResponse.text
|
|
|
|
d.responseTimestamp = Date.now()
|
|
|
|
root.close()
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-17 10:25:48 +00:00
|
|
|
}
|
2022-06-28 18:11:18 +00:00
|
|
|
}
|