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-10-19 11:56:35 +00:00
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.popups 1.0
|
2021-05-26 17:36:24 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
import "../../Profile/Sections/Contacts"
|
|
|
|
import "../panels"
|
|
|
|
|
2021-10-14 09:50:59 +00:00
|
|
|
// TODO: Replace with StatusModal
|
2021-05-26 17:36:24 +00:00
|
|
|
ModalPopup {
|
|
|
|
id: popup
|
|
|
|
|
2021-10-22 20:49:47 +00:00
|
|
|
property var store
|
2021-12-09 16:25:38 +00:00
|
|
|
// Important:
|
|
|
|
// We're here in case of ChatSection
|
|
|
|
// This module is set from `ChatLayout` (each `ChatLayout` has its own chatSectionModule)
|
|
|
|
property var chatSectionModule
|
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
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.leftMargin: -Style.current.halfPadding
|
|
|
|
anchors.rightMargin: -Style.current.halfPadding
|
|
|
|
|
2021-11-15 15:15:21 +00:00
|
|
|
model: popup.store.contactRequests
|
2021-05-26 17:36:24 +00:00
|
|
|
clip: true
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
delegate: ContactRequestPanel {
|
2021-05-26 17:36:24 +00:00
|
|
|
name: Utils.removeStatusEns(model.name)
|
|
|
|
address: model.address
|
|
|
|
localNickname: model.localNickname
|
|
|
|
identicon: model.thumbnailImage || model.identicon
|
|
|
|
profileClick: function (showFooter, userName, fromAuthor, identicon, textParam, nickName) {
|
2021-12-31 12:29:51 +00:00
|
|
|
Global.openProfilePopup(fromAuthor)
|
2021-05-26 17:36:24 +00:00
|
|
|
}
|
|
|
|
onBlockContactActionTriggered: {
|
|
|
|
blockContactConfirmationDialog.contactName = name
|
|
|
|
blockContactConfirmationDialog.contactAddress = address
|
|
|
|
blockContactConfirmationDialog.open()
|
|
|
|
}
|
2021-10-01 15:58:36 +00:00
|
|
|
onAcceptClicked: {
|
2021-12-09 16:25:38 +00:00
|
|
|
chatSectionModule.createOneToOneChat(model.address, "")
|
2021-11-15 15:15:21 +00:00
|
|
|
popup.store.contactsModuleInst.addContact(model.address)
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
|
|
|
onDeclineClicked: {
|
2021-11-15 15:15:21 +00:00
|
|
|
popup.store.contactsModuleInst.rejectContactRequest(model.address)
|
2021-10-01 15:58:36 +00:00
|
|
|
}
|
2021-05-26 17:36:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
|
|
|
width: parent.width
|
|
|
|
height: children[0].height
|
|
|
|
|
|
|
|
BlockContactConfirmationDialog {
|
|
|
|
id: blockContactConfirmationDialog
|
|
|
|
onBlockButtonClicked: {
|
2021-11-15 15:15:21 +00:00
|
|
|
popup.store.contactsModuleInst.blockContact(blockContactConfirmationDialog.contactAddress)
|
2021-05-26 17:36:24 +00:00
|
|
|
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-11-15 15:15:21 +00:00
|
|
|
const requests = popup.store.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
|
|
|
}
|
2021-11-15 15:15:21 +00:00
|
|
|
popup.store.contactsModuleInst.rejectContactRequests(JSON.stringify(pubkeys))
|
2021-05-26 17:36:24 +00:00
|
|
|
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-11-15 15:15:21 +00:00
|
|
|
const requests = popup.store.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
|
|
|
}
|
2021-11-15 15:15:21 +00:00
|
|
|
popup.store.contactsModuleInst.acceptContactRequests(JSON.stringify(pubkeys))
|
2021-05-26 17:36:24 +00:00
|
|
|
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
|
2021-10-19 11:56:35 +00:00
|
|
|
type: StatusBaseButton.Type.Danger
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|