2021-05-26 17:36:24 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-05-26 17:36:24 +00:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
2021-10-14 09:50:59 +00:00
|
|
|
import "../../../../shared/popups"
|
2021-05-26 17:36:24 +00:00
|
|
|
|
2021-10-14 09:50:59 +00:00
|
|
|
// TODO: Replace with StatusModal
|
2021-05-26 17:36:24 +00:00
|
|
|
ModalPopup {
|
|
|
|
id: popup
|
|
|
|
|
|
|
|
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Contact requests"
|
|
|
|
title: qsTrId("contact-requests")
|
2021-05-26 17:36:24 +00:00
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: contactList
|
|
|
|
|
|
|
|
property Component profilePopupComponent: ProfilePopup {
|
|
|
|
id: profilePopup
|
|
|
|
onClosed: destroy()
|
|
|
|
}
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.leftMargin: -Style.current.halfPadding
|
|
|
|
anchors.rightMargin: -Style.current.halfPadding
|
|
|
|
|
|
|
|
model: profileModel.contacts.contactRequests
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
delegate: ContactRequest {
|
|
|
|
name: Utils.removeStatusEns(model.name)
|
|
|
|
address: model.address
|
|
|
|
localNickname: model.localNickname
|
|
|
|
identicon: model.thumbnailImage || model.identicon
|
|
|
|
profileClick: function (showFooter, userName, fromAuthor, identicon, textParam, nickName) {
|
|
|
|
var popup = profilePopupComponent.createObject(contactList);
|
|
|
|
popup.openPopup(showFooter, userName, fromAuthor, identicon, textParam, nickName);
|
|
|
|
}
|
|
|
|
onBlockContactActionTriggered: {
|
|
|
|
blockContactConfirmationDialog.contactName = name
|
|
|
|
blockContactConfirmationDialog.contactAddress = address
|
|
|
|
blockContactConfirmationDialog.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
|
|
|
width: parent.width
|
|
|
|
height: children[0].height
|
|
|
|
|
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
onBlockButtonClicked: {
|
|
|
|
profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
|
|
|
|
blockContactConfirmationDialog.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
id: declineAllDialog
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Decline all contacts"
|
2021-09-09 09:10:29 +00:00
|
|
|
header.title: qsTrId("decline-all-contacts")
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Are you sure you want to decline all these contact requests"
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-decline-all-these-contact-requests")
|
2021-05-26 17:36:24 +00:00
|
|
|
onConfirmButtonClicked: {
|
2021-07-12 08:35:05 +00:00
|
|
|
const requests = profileModel.contacts.contactRequests
|
2021-05-26 17:36:24 +00:00
|
|
|
const pubkeys = []
|
2021-07-12 08:35:05 +00:00
|
|
|
for (let i = 0; i < requests.count; i++) {
|
|
|
|
pubkeys.push(requests.rowData(i, "address"))
|
2021-05-26 17:36:24 +00:00
|
|
|
}
|
|
|
|
profileModel.contacts.rejectContactRequests(JSON.stringify(pubkeys))
|
|
|
|
declineAllDialog.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
id: acceptAllDialog
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Accept all contacts"
|
2021-09-09 09:10:29 +00:00
|
|
|
header.title: qsTrId("accept-all-contacts")
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Are you sure you want to accept all these contact requests"
|
|
|
|
confirmationText: qsTrId("are-you-sure-you-want-to-accept-all-these-contact-requests")
|
2021-05-26 17:36:24 +00:00
|
|
|
onConfirmButtonClicked: {
|
2021-07-12 08:35:05 +00:00
|
|
|
const requests = profileModel.contacts.contactRequests
|
2021-05-26 17:36:24 +00:00
|
|
|
const pubkeys = []
|
2021-07-12 08:35:05 +00:00
|
|
|
for (let i = 0; i < requests.count; i++) {
|
|
|
|
pubkeys.push(requests.rowData(i, "address"))
|
2021-05-26 17:36:24 +00:00
|
|
|
}
|
|
|
|
profileModel.contacts.acceptContactRequests(JSON.stringify(pubkeys))
|
|
|
|
acceptAllDialog.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: blockBtn
|
2021-05-26 20:04:42 +00:00
|
|
|
enabled: contactList.count > 0
|
2021-05-26 17:36:24 +00:00
|
|
|
anchors.right: addToContactsButton.left
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
type: "warn"
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Decline all"
|
|
|
|
text: qsTrId("decline-all")
|
2021-05-26 17:36:24 +00:00
|
|
|
onClicked: declineAllDialog.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: addToContactsButton
|
2021-05-26 20:04:42 +00:00
|
|
|
enabled: contactList.count > 0
|
2021-05-26 17:36:24 +00:00
|
|
|
anchors.right: parent.right
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Accept all"
|
|
|
|
text: qsTrId("accept-all")
|
2021-05-26 17:36:24 +00:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
onClicked: acceptAllDialog.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|