2021-02-08 12:21:23 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.status 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2021-03-31 19:14:09 +00:00
|
|
|
// TODO move Contact into shared to get rid of that import
|
2022-03-08 18:49:33 +00:00
|
|
|
import AppLayouts.Chat.controls 1.0
|
2021-02-08 12:21:23 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2022-04-06 17:13:49 +00:00
|
|
|
height: visible ? Math.min(contactListView.contentHeight, (expanded ? 320 : 192)) : 0
|
2022-01-04 12:06:05 +00:00
|
|
|
|
|
|
|
property var contactsStore
|
2022-01-10 16:44:54 +00:00
|
|
|
property var community
|
2022-01-04 12:06:05 +00:00
|
|
|
|
2021-02-08 12:21:23 +00:00
|
|
|
property string filterText: ""
|
|
|
|
property bool expanded: true
|
2021-03-31 19:14:09 +00:00
|
|
|
property bool showCheckbox: false
|
2021-05-17 09:56:55 +00:00
|
|
|
property bool hideCommunityMembers: false
|
2021-03-31 19:14:09 +00:00
|
|
|
property var pubKeys: ([])
|
2021-02-08 12:21:23 +00:00
|
|
|
signal contactClicked(var contact)
|
|
|
|
|
|
|
|
function matchesAlias(name, filter) {
|
|
|
|
let parts = name.split(" ")
|
|
|
|
return parts.some(p => p.startsWith(filter))
|
|
|
|
}
|
|
|
|
|
2021-06-10 21:07:41 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2021-02-08 12:21:23 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
ScrollBar.vertical.policy: contactListView.contentHeight > contactListView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
clip: true
|
|
|
|
id: contactListView
|
2022-01-04 12:06:05 +00:00
|
|
|
model: root.contactsStore.myContactsModel
|
2021-02-08 12:21:23 +00:00
|
|
|
delegate: Contact {
|
2021-03-31 19:14:09 +00:00
|
|
|
showCheckbox: root.showCheckbox
|
|
|
|
isChecked: root.pubKeys.indexOf(model.pubKey) > -1
|
2021-02-08 12:21:23 +00:00
|
|
|
pubKey: model.pubKey
|
2022-06-20 13:27:00 +00:00
|
|
|
isContact: model.isContact
|
2021-02-08 12:21:23 +00:00
|
|
|
isUser: false
|
2022-06-20 13:27:00 +00:00
|
|
|
name: model.displayName
|
2022-03-30 15:30:28 +00:00
|
|
|
image: model.icon
|
2022-01-10 16:44:54 +00:00
|
|
|
isVisible: {
|
2022-06-20 13:27:00 +00:00
|
|
|
return model.isContact && !model.isBlocked && (root.filterText === "" ||
|
|
|
|
root.matchesAlias(model.alias.toLowerCase(), root.filterText.toLowerCase()) ||
|
|
|
|
model.displayName.toLowerCase().includes(root.filterText.toLowerCase()) ||
|
|
|
|
model.ensName.toLowerCase().includes(root.filterText.toLowerCase()) ||
|
|
|
|
model.localNickname.toLowerCase().includes(root.filterText.toLowerCase()) ||
|
2022-01-04 12:06:05 +00:00
|
|
|
model.pubKey.toLowerCase().includes(root.filterText.toLowerCase())) &&
|
2022-01-10 16:44:54 +00:00
|
|
|
(!root.hideCommunityMembers ||
|
2022-06-20 13:27:00 +00:00
|
|
|
!root.community.hasMember(model.pubKey))
|
2022-01-10 16:44:54 +00:00
|
|
|
}
|
2021-02-08 12:21:23 +00:00
|
|
|
onContactClicked: function () {
|
|
|
|
root.contactClicked(model)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|