2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-24 03:23:49 +00:00
|
|
|
|
2020-05-25 20:34:26 +00:00
|
|
|
import "../../../imports"
|
2020-05-27 21:09:12 +00:00
|
|
|
import "../../../shared"
|
2021-05-26 17:36:24 +00:00
|
|
|
import "../../../shared/status"
|
2020-05-26 18:16:07 +00:00
|
|
|
import "./components"
|
2020-05-28 00:21:02 +00:00
|
|
|
import "./ContactsColumn"
|
2020-12-11 20:38:10 +00:00
|
|
|
import "./CommunityComponents"
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2021-06-30 14:17:05 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
Item {
|
2021-07-20 15:22:09 +00:00
|
|
|
id: contactsColumn
|
2021-07-22 14:53:19 +00:00
|
|
|
width: 304
|
|
|
|
height: parent.height
|
|
|
|
|
2021-06-30 14:17:05 +00:00
|
|
|
property int chatGroupsListViewCount: channelList.chatListItems.count
|
2020-06-15 16:24:21 +00:00
|
|
|
property alias searchStr: searchBox.text
|
2021-07-20 15:22:09 +00:00
|
|
|
signal openProfileClicked()
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-07-15 15:50:50 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
//steal focus from search field
|
|
|
|
addChat.forceActiveFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-30 14:17:05 +00:00
|
|
|
StatusNavigationPanelHeadline {
|
|
|
|
id: headline
|
2020-05-27 18:40:58 +00:00
|
|
|
anchors.top: parent.top
|
2021-06-30 14:17:05 +00:00
|
|
|
anchors.topMargin: 16
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Chat"
|
|
|
|
text: qsTrId("chat")
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
|
|
|
anchors.top: headline.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.right: addChat.left
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.padding
|
2021-07-15 15:50:50 +00:00
|
|
|
Keys.onEscapePressed: {
|
|
|
|
addChat.forceActiveFocus();
|
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AddChat {
|
|
|
|
id: addChat
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.top: headline.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusContactRequestsIndicatorListItem {
|
|
|
|
id: contactRequests
|
|
|
|
|
|
|
|
property int nbRequests: profileModel.contacts.contactRequests.count
|
|
|
|
|
|
|
|
anchors.top: searchBox.bottom
|
|
|
|
anchors.topMargin: visible ? Style.current.padding : 0
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
visible: nbRequests > 0
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Contact requests"
|
|
|
|
title: qsTrId("contact-requests")
|
2021-06-30 14:17:05 +00:00
|
|
|
requestsCount: nbRequests
|
|
|
|
|
|
|
|
sensor.onClicked: openPopup(contactRequestsPopup)
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
id: chatGroupsContainer
|
|
|
|
|
2021-07-15 15:50:50 +00:00
|
|
|
width: parent.width
|
|
|
|
height: (contentHeight < (parent.height - contactRequests.height - Style.current.padding)) ? contentHeight : (parent.height - contactRequests.height - Style.current.padding)
|
2021-06-30 14:17:05 +00:00
|
|
|
anchors.top: contactRequests.bottom
|
2020-07-15 19:38:03 +00:00
|
|
|
anchors.topMargin: Style.current.padding
|
2021-07-15 15:50:50 +00:00
|
|
|
contentHeight: channelList.height + 2 * Style.current.padding + emptyViewAndSuggestions.height + emptyViewAndSuggestions.anchors.topMargin
|
2020-05-27 18:40:58 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-06-30 14:17:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
leftPadding: Style.current.halfPadding
|
|
|
|
rightPadding: Style.current.halfPadding
|
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: noSearchResults
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: parent.width
|
|
|
|
visible: !!!channelList.height && contactsColumn.searchStr !== ""
|
|
|
|
height: visible ? 300 : 0
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor5
|
|
|
|
anchors.centerIn: parent
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "No search results"
|
|
|
|
text: qsTrId("no-search-results")
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusChatList {
|
|
|
|
id: channelList
|
|
|
|
|
|
|
|
chatNameFn: function (chatItem) {
|
|
|
|
return chatItem.chatType !== Constants.chatTypePublic ?
|
2021-07-15 15:50:50 +00:00
|
|
|
Emoji.parse(Utils.removeStatusEns(Utils.filterXSS(chatItem.name))) :
|
|
|
|
Utils.filterXSS(chatItem.name)
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
profileImageFn: function (id) {
|
|
|
|
return appMain.getProfileImage(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
filterFn: function (chatListItem) {
|
|
|
|
return !!!contactsColumn.searchStr || chatListItem.name.toLowerCase().includes(contactsColumn.searchStr.toLowerCase())
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: profileModel.contacts.list
|
|
|
|
onContactChanged: {
|
|
|
|
for (var i = 0; i < channelList.chatListItems.count; i++) {
|
|
|
|
let chatItem = channelList.chatListItems.itemAt(i);
|
|
|
|
if (chatItem.chatId === pubkey) {
|
|
|
|
let profileImage = appMain.getProfileImage(pubkey)
|
|
|
|
if (!!profileImage) {
|
|
|
|
chatItem.image.isIdenticon = false
|
|
|
|
chatItem.image.source = profileImage
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
chatListItems.model: chatsModel.channelView.chats
|
|
|
|
selectedChatId: chatsModel.channelView.activeChannel.id
|
|
|
|
|
|
|
|
onChatItemSelected: chatsModel.channelView.setActiveChannel(id)
|
|
|
|
onChatItemUnmuted: chatsModel.channelView.unmuteChatItem(id)
|
|
|
|
|
2021-07-06 09:42:51 +00:00
|
|
|
popupMenu: ChatContextMenu {
|
2021-06-30 14:17:05 +00:00
|
|
|
openHandler: function (id) {
|
|
|
|
chatItem = chatsModel.channelView.getChatItemById(id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EmptyView {
|
|
|
|
id: emptyViewAndSuggestions
|
|
|
|
width: parent.width
|
|
|
|
visible: !appSettings.hideChannelSuggestions && !noSearchResults.visible
|
|
|
|
anchors.top: noSearchResults.visible ? noSearchResults.bottom : channelList.bottom
|
|
|
|
anchors.topMargin: 32
|
|
|
|
}
|
2020-05-27 18:40:58 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: publicChatPopupComponent
|
|
|
|
PublicChatPopup {
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 20:11:56 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: groupChatPopupComponent
|
|
|
|
GroupChatPopup {
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-06-17 15:56:48 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: privateChatPopupComponent
|
|
|
|
PrivateChatPopup {
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2021-07-20 15:22:09 +00:00
|
|
|
onProfileClicked: {
|
|
|
|
contactsColumn.openProfileClicked();
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communitiesPopupComponent
|
|
|
|
CommunitiesPopup {
|
2021-07-19 11:21:05 +00:00
|
|
|
anchors.centerIn: parent
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: createCommunitiesPopupComponent
|
|
|
|
CreateCommunityPopup {
|
2021-07-16 10:11:03 +00:00
|
|
|
anchors.centerIn: parent
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-18 20:55:33 +00:00
|
|
|
Component {
|
|
|
|
id: importCommunitiesPopupComponent
|
2021-02-12 18:19:31 +00:00
|
|
|
AccessExistingCommunityPopup {
|
2020-12-18 20:55:33 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: communityDetailPopup
|
|
|
|
CommunityDetailPopup {
|
2021-07-19 12:25:52 +00:00
|
|
|
anchors.centerIn: parent
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 12:56:43 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 17:36:24 +00:00
|
|
|
Component {
|
|
|
|
id: contactRequestsPopup
|
|
|
|
ContactRequestsPopup {
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 19:19:34 +00:00
|
|
|
|
2021-07-16 05:37:07 +00:00
|
|
|
Connections {
|
|
|
|
target: chatsModel.communities
|
|
|
|
onImportingCommunityStateChanged: {
|
|
|
|
if (state !== Constants.communityImported &&
|
|
|
|
state !== Constants.communityImportingInProgress &&
|
|
|
|
state !== Constants.communityImportingError)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state === Constants.communityImported)
|
|
|
|
{
|
|
|
|
if (toastMessage.uuid !== communityImportingProcessId)
|
|
|
|
return
|
|
|
|
|
|
|
|
toastMessage.close()
|
|
|
|
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Community imported"
|
|
|
|
toastMessage.title = qsTrId("community-imported")
|
2021-07-16 05:37:07 +00:00
|
|
|
toastMessage.source = ""
|
|
|
|
toastMessage.iconRotates = false
|
|
|
|
toastMessage.dissapearInMs = 4000
|
|
|
|
}
|
|
|
|
else if (state === Constants.communityImportingInProgress)
|
|
|
|
{
|
|
|
|
toastMessage.uuid = communityImportingProcessId
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Importing community is in progress"
|
|
|
|
toastMessage.title = qsTrId("importing-community-is-in-progress")
|
2021-07-16 05:37:07 +00:00
|
|
|
toastMessage.source = "../../img/loading.svg"
|
|
|
|
toastMessage.iconRotates = true
|
|
|
|
toastMessage.dissapearInMs = -1
|
|
|
|
}
|
|
|
|
else if (state === Constants.communityImportingError)
|
|
|
|
{
|
|
|
|
if (toastMessage.uuid !== communityImportingProcessId)
|
|
|
|
return
|
|
|
|
|
|
|
|
toastMessage.close()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
toastMessage.displayCloseButton = false
|
|
|
|
toastMessage.displayLink = false
|
|
|
|
toastMessage.iconColor = Style.current.primary
|
|
|
|
toastMessage.open()
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 19:19:34 +00:00
|
|
|
}
|