2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2021-10-26 14:21:08 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-25 19:37:44 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2024-11-06 20:08:22 +00:00
|
|
|
import StatusQ.Core 0.1
|
2021-10-25 19:37:44 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2024-11-06 20:08:22 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2021-10-25 19:37:44 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-26 14:21:08 +00:00
|
|
|
|
2024-10-22 12:39:42 +00:00
|
|
|
import shared.controls 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2024-10-22 12:39:42 +00:00
|
|
|
import shared.stores 1.0 as SharedStores
|
|
|
|
import shared.views 1.0
|
2022-07-06 19:27:04 +00:00
|
|
|
import shared.views.chat 1.0
|
2021-10-06 09:16:39 +00:00
|
|
|
|
2021-12-31 12:29:51 +00:00
|
|
|
import "../stores"
|
2021-10-06 09:16:39 +00:00
|
|
|
import "../panels"
|
|
|
|
import "../popups"
|
2020-05-27 21:28:25 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
SettingsContentBase {
|
2021-10-06 09:16:39 +00:00
|
|
|
id: root
|
2024-10-22 12:39:42 +00:00
|
|
|
|
2021-12-31 12:29:51 +00:00
|
|
|
property ContactsStore contactsStore
|
2024-10-22 12:39:42 +00:00
|
|
|
property SharedStores.UtilsStore utilsStore
|
|
|
|
|
2020-07-24 11:27:26 +00:00
|
|
|
property alias searchStr: searchBox.text
|
2020-09-17 08:47:14 +00:00
|
|
|
property bool isPending: false
|
2022-03-28 14:42:26 +00:00
|
|
|
|
2022-10-28 08:24:23 +00:00
|
|
|
titleRowComponentLoader.sourceComponent: StatusButton {
|
2022-10-26 20:00:40 +00:00
|
|
|
objectName: "ContactsView_ContactRequest_Button"
|
2022-10-28 08:24:23 +00:00
|
|
|
text: qsTr("Send contact request to chat key")
|
|
|
|
onClicked: {
|
2023-05-23 12:46:16 +00:00
|
|
|
Global.openPopup(sendContactRequest);
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-10-28 08:24:23 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
|
2024-11-07 14:29:28 +00:00
|
|
|
function openContextMenu(model, pubKey) {
|
|
|
|
const entry = ModelUtils.getByKey(model, "pubKey", pubKey)
|
|
|
|
|
|
|
|
const profileType = Utils.getProfileType(entry.isCurrentUser, false, entry.isBlocked)
|
|
|
|
const contactType = Utils.getContactType(entry.contactRequest, entry.isContact)
|
2024-09-06 15:55:44 +00:00
|
|
|
|
2024-11-07 14:29:28 +00:00
|
|
|
const params = {
|
|
|
|
pubKey, profileType, contactType,
|
|
|
|
compressedPubKey: entry.compressedPubKey,
|
2024-11-07 10:43:06 +00:00
|
|
|
emojiHash: root.utilsStore.getEmojiHash(pubKey),
|
2024-11-07 14:29:28 +00:00
|
|
|
displayName: entry.preferredDisplayName,
|
|
|
|
userIcon: entry.icon,
|
|
|
|
colorHash: entry.colorHash,
|
|
|
|
colorId: entry.colorId,
|
|
|
|
trustStatus: entry.trustStatus,
|
|
|
|
onlineStatus: entry.onlineStatus,
|
|
|
|
ensVerified: entry.isEnsVerified,
|
|
|
|
hasLocalNickname: !!entry.localNickname
|
|
|
|
}
|
2022-07-06 19:27:04 +00:00
|
|
|
|
2024-11-07 14:29:28 +00:00
|
|
|
Global.openMenu(contactContextMenuComponent, this, params)
|
2024-11-06 20:08:22 +00:00
|
|
|
}
|
|
|
|
|
2022-06-03 15:32:03 +00:00
|
|
|
Item {
|
|
|
|
id: contentItem
|
2022-08-18 14:41:02 +00:00
|
|
|
width: root.contentWidth
|
|
|
|
height: (searchBox.height + contactsTabBar.height
|
2024-10-15 19:26:12 +00:00
|
|
|
+ stackLayout.height + (2 * Theme.bigPadding))
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
Component {
|
|
|
|
id: contactContextMenuComponent
|
|
|
|
ProfileContextMenu {
|
|
|
|
id: contactContextMenu
|
2022-07-06 19:27:04 +00:00
|
|
|
|
2024-11-07 10:43:06 +00:00
|
|
|
property string pubKey
|
|
|
|
|
|
|
|
onOpenProfileClicked: Global.openProfilePopup(contactContextMenu.pubKey, null, null)
|
|
|
|
onReviewContactRequest: Global.openReviewContactRequestPopup(contactContextMenu.pubKey, null)
|
|
|
|
onSendContactRequest: Global.openContactRequestPopup(contactContextMenu.pubKey, null)
|
|
|
|
onEditNickname: Global.openNicknamePopupRequested(contactContextMenu.pubKey, null)
|
|
|
|
onUnblockContact: Global.unblockContactRequested(contactContextMenu.pubKey)
|
|
|
|
onMarkAsUntrusted: Global.markAsUntrustedRequested(contactContextMenu.pubKey)
|
|
|
|
onRemoveContact: Global.removeContactRequested(contactContextMenu.pubKey)
|
|
|
|
onBlockContact: Global.blockContactRequested(contactContextMenu.pubKey)
|
2024-11-08 11:36:44 +00:00
|
|
|
|
|
|
|
onCreateOneToOneChat: root.contactsStore.joinPrivateChat(contactContextMenu.pubKey)
|
|
|
|
onRemoveTrustStatus: root.contactsStore.removeTrustStatus(contactContextMenu.pubKey)
|
|
|
|
onRemoveNickname: root.contactsStore.changeContactNickname(contactContextMenu.pubKey, "",
|
|
|
|
contactContextMenu.displayName, true)
|
2024-11-04 21:47:59 +00:00
|
|
|
onMarkAsTrusted: Global.openMarkAsIDVerifiedPopup(contactContextMenu.pubKey, null)
|
|
|
|
onRemoveTrustedMark: Global.openRemoveIDVerificationDialog(contactContextMenu.pubKey, null)
|
2024-10-02 12:54:11 +00:00
|
|
|
onClosed: destroy()
|
2022-07-06 19:27:04 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-14 20:09:07 +00:00
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
2022-06-03 15:32:03 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2022-07-22 10:28:04 +00:00
|
|
|
placeholderText: qsTr("Search by a display name or chat key")
|
2020-07-21 21:03:22 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 11:45:29 +00:00
|
|
|
StatusTabBar {
|
2022-03-15 15:55:18 +00:00
|
|
|
id: contactsTabBar
|
2022-06-03 15:32:03 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: searchBox.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.padding
|
2022-09-12 09:54:07 +00:00
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
StatusTabButton {
|
|
|
|
id: contactsBtn
|
2024-10-15 19:26:12 +00:00
|
|
|
leftPadding: Theme.padding
|
2022-05-23 11:45:29 +00:00
|
|
|
width: implicitWidth
|
|
|
|
text: qsTr("Contacts")
|
2021-01-14 20:09:07 +00:00
|
|
|
}
|
2022-03-15 15:55:18 +00:00
|
|
|
StatusTabButton {
|
|
|
|
id: pendingRequestsBtn
|
2022-10-26 20:00:40 +00:00
|
|
|
objectName: "ContactsView_PendingRequest_Button"
|
2022-05-23 11:45:29 +00:00
|
|
|
width: implicitWidth
|
2022-03-24 20:55:22 +00:00
|
|
|
enabled: root.contactsStore.receivedContactRequestsModel.count > 0 ||
|
|
|
|
root.contactsStore.sentContactRequestsModel.count > 0
|
2022-05-23 11:45:29 +00:00
|
|
|
text: qsTr("Pending Requests")
|
2022-05-16 15:02:03 +00:00
|
|
|
badge.value: root.contactsStore.receivedContactRequestsModel.count
|
2022-03-15 15:55:18 +00:00
|
|
|
}
|
|
|
|
StatusTabButton {
|
|
|
|
id: blockedBtn
|
2024-07-18 10:57:24 +00:00
|
|
|
objectName: "ContactsView_Blocked_Button"
|
2022-05-23 11:45:29 +00:00
|
|
|
width: implicitWidth
|
2022-03-15 15:55:18 +00:00
|
|
|
enabled: root.contactsStore.blockedContactsModel.count > 0
|
2022-05-23 11:45:29 +00:00
|
|
|
text: qsTr("Blocked")
|
2021-01-14 20:09:07 +00:00
|
|
|
}
|
2020-07-24 11:27:26 +00:00
|
|
|
}
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackLayout
|
2022-06-03 15:32:03 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: contactsTabBar.bottom
|
2022-03-15 15:55:18 +00:00
|
|
|
currentIndex: contactsTabBar.currentIndex
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.padding
|
2022-03-15 15:55:18 +00:00
|
|
|
// CONTACTS
|
2022-08-18 14:41:02 +00:00
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.minimumHeight: 0
|
|
|
|
Layout.maximumHeight: (verifiedContacts.height + mutualContacts.height + noFriendsItem.height)
|
|
|
|
visible: (stackLayout.currentIndex === 0)
|
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
|
|
|
stackLayout.height = height+contactsTabBar.anchors.topMargin;
|
|
|
|
}
|
|
|
|
}
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.padding
|
2022-06-03 15:32:03 +00:00
|
|
|
ContactsListPanel {
|
|
|
|
id: verifiedContacts
|
2022-08-18 14:41:02 +00:00
|
|
|
Layout.fillWidth: true
|
2024-10-29 18:08:12 +00:00
|
|
|
title: qsTr("Trusted Contacts")
|
2022-12-01 16:03:42 +00:00
|
|
|
visible: !noFriendsItem.visible && count > 0
|
2022-06-03 15:32:03 +00:00
|
|
|
contactsModel: root.contactsStore.myContactsModel
|
|
|
|
searchString: searchBox.text
|
2024-11-07 14:29:28 +00:00
|
|
|
onOpenContactContextMenu: root.openContextMenu(contactsModel, publicKey)
|
2022-07-06 19:27:04 +00:00
|
|
|
panelUsage: Constants.contactsPanelUsage.verifiedMutualContacts
|
2022-06-03 15:32:03 +00:00
|
|
|
onSendMessageActionTriggered: {
|
|
|
|
root.contactsStore.joinPrivateChat(publicKey)
|
2022-03-15 15:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-21 21:03:22 +00:00
|
|
|
|
2022-06-03 15:32:03 +00:00
|
|
|
ContactsListPanel {
|
|
|
|
id: mutualContacts
|
2022-08-18 14:41:02 +00:00
|
|
|
Layout.fillWidth: true
|
2022-12-01 16:03:42 +00:00
|
|
|
visible: !noFriendsItem.visible && count > 0
|
2022-06-03 15:32:03 +00:00
|
|
|
title: qsTr("Contacts")
|
|
|
|
contactsModel: root.contactsStore.myContactsModel
|
|
|
|
searchString: searchBox.text
|
2024-11-07 14:29:28 +00:00
|
|
|
onOpenContactContextMenu: root.openContextMenu(contactsModel, publicKey)
|
2022-07-06 19:27:04 +00:00
|
|
|
panelUsage: Constants.contactsPanelUsage.mutualContacts
|
2022-06-03 15:32:03 +00:00
|
|
|
|
|
|
|
onSendMessageActionTriggered: {
|
|
|
|
root.contactsStore.joinPrivateChat(publicKey)
|
|
|
|
}
|
|
|
|
}
|
2022-08-18 14:41:02 +00:00
|
|
|
|
2022-06-03 15:32:03 +00:00
|
|
|
Item {
|
2022-08-18 14:41:02 +00:00
|
|
|
id: noFriendsItem
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: visible ? (root.contentHeight - (2*searchBox.height) - contactsTabBar.height - contactsTabBar.anchors.topMargin) : 0
|
|
|
|
visible: root.contactsStore.myContactsModel.count === 0
|
2022-06-03 15:32:03 +00:00
|
|
|
NoFriendsRectangle {
|
|
|
|
anchors.centerIn: parent
|
2024-09-06 15:55:44 +00:00
|
|
|
text: qsTr("You don't have any contacts yet")
|
2022-06-03 15:32:03 +00:00
|
|
|
}
|
2022-03-15 15:55:18 +00:00
|
|
|
}
|
2021-09-17 15:08:16 +00:00
|
|
|
}
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
// PENDING REQUESTS
|
2022-08-18 14:41:02 +00:00
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.minimumHeight: 0
|
|
|
|
Layout.maximumHeight: (receivedRequests.height + sentRequests.height)
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.padding
|
2022-08-18 14:41:02 +00:00
|
|
|
visible: (stackLayout.currentIndex === 1)
|
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
|
|
|
stackLayout.height = height+contactsTabBar.anchors.topMargin;
|
|
|
|
}
|
|
|
|
}
|
2022-06-03 15:32:03 +00:00
|
|
|
ContactsListPanel {
|
|
|
|
id: receivedRequests
|
2022-12-26 21:53:47 +00:00
|
|
|
objectName: "receivedRequests_ContactsListPanel"
|
2022-08-18 14:41:02 +00:00
|
|
|
Layout.fillWidth: true
|
2022-06-03 15:32:03 +00:00
|
|
|
title: qsTr("Received")
|
|
|
|
searchString: searchBox.text
|
2022-12-01 16:03:42 +00:00
|
|
|
visible: count > 0
|
2024-11-07 14:29:28 +00:00
|
|
|
onOpenContactContextMenu: root.openContextMenu(contactsModel, publicKey)
|
2022-06-03 15:32:03 +00:00
|
|
|
contactsModel: root.contactsStore.receivedContactRequestsModel
|
|
|
|
panelUsage: Constants.contactsPanelUsage.receivedContactRequest
|
|
|
|
|
2022-09-27 21:26:26 +00:00
|
|
|
onSendMessageActionTriggered: {
|
|
|
|
root.contactsStore.joinPrivateChat(publicKey)
|
|
|
|
}
|
|
|
|
|
2022-06-03 15:32:03 +00:00
|
|
|
onContactRequestAccepted: {
|
2023-04-03 16:27:56 +00:00
|
|
|
root.contactsStore.acceptContactRequest(publicKey, "")
|
2022-03-24 20:55:22 +00:00
|
|
|
}
|
|
|
|
|
2022-06-03 15:32:03 +00:00
|
|
|
onContactRequestRejected: {
|
2023-04-03 16:27:56 +00:00
|
|
|
root.contactsStore.dismissContactRequest(publicKey, "")
|
2022-06-03 15:32:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ContactsListPanel {
|
|
|
|
id: sentRequests
|
2022-10-26 20:00:40 +00:00
|
|
|
objectName: "sentRequests_ContactsListPanel"
|
2022-08-18 14:41:02 +00:00
|
|
|
Layout.fillWidth: true
|
2022-06-03 15:32:03 +00:00
|
|
|
title: qsTr("Sent")
|
|
|
|
searchString: searchBox.text
|
2022-12-01 16:03:42 +00:00
|
|
|
visible: count > 0
|
2024-11-07 14:29:28 +00:00
|
|
|
onOpenContactContextMenu: root.openContextMenu(contactsModel, publicKey)
|
2022-06-03 15:32:03 +00:00
|
|
|
contactsModel: root.contactsStore.sentContactRequestsModel
|
|
|
|
panelUsage: Constants.contactsPanelUsage.sentContactRequest
|
2022-03-24 20:55:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
// BLOCKED
|
2021-10-06 09:16:39 +00:00
|
|
|
ContactsListPanel {
|
2022-08-18 14:41:02 +00:00
|
|
|
Layout.fillWidth: true
|
2022-03-24 20:55:22 +00:00
|
|
|
searchString: searchBox.text
|
2024-11-07 14:29:28 +00:00
|
|
|
onOpenContactContextMenu: root.openContextMenu(contactsModel, publicKey)
|
2021-12-31 12:29:51 +00:00
|
|
|
contactsModel: root.contactsStore.blockedContactsModel
|
2022-03-24 20:55:22 +00:00
|
|
|
panelUsage: Constants.contactsPanelUsage.blockedContacts
|
2022-08-18 14:41:02 +00:00
|
|
|
visible: (stackLayout.currentIndex === 2)
|
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
|
|
|
stackLayout.height = height;
|
|
|
|
}
|
|
|
|
}
|
2021-01-14 20:09:07 +00:00
|
|
|
}
|
2020-09-17 08:47:14 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 20:09:07 +00:00
|
|
|
Component {
|
|
|
|
id: loadingIndicator
|
2021-04-26 10:25:01 +00:00
|
|
|
StatusLoadingIndicator {
|
2021-01-14 20:09:07 +00:00
|
|
|
width: 12
|
|
|
|
height: 12
|
|
|
|
}
|
|
|
|
}
|
2020-06-16 18:04:56 +00:00
|
|
|
|
2023-05-23 12:46:16 +00:00
|
|
|
Component {
|
2022-05-07 11:45:15 +00:00
|
|
|
id: sendContactRequest
|
2023-05-23 12:46:16 +00:00
|
|
|
SendContactRequestModal {
|
2022-05-07 11:45:15 +00:00
|
|
|
contactsStore: root.contactsStore
|
2023-08-01 12:32:03 +00:00
|
|
|
onClosed: destroy()
|
2022-03-28 14:42:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-16 18:04:56 +00:00
|
|
|
}
|