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
|
|
|
|
2022-07-14 11:03:36 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
2022-03-23 10:56:25 +00:00
|
|
|
import shared.popups 1.0
|
2021-10-01 15:58:36 +00:00
|
|
|
|
2022-08-17 14:48:05 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
import "../panels"
|
|
|
|
import "../popups"
|
|
|
|
import "../popups/community"
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2021-06-30 14:17:05 +00:00
|
|
|
Item {
|
2021-10-21 22:39:53 +00:00
|
|
|
id: root
|
2021-07-22 14:53:19 +00:00
|
|
|
width: 304
|
|
|
|
height: parent.height
|
|
|
|
|
2021-11-26 15:37:57 +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-10-21 22:39:53 +00:00
|
|
|
property var store
|
2022-01-04 12:06:05 +00:00
|
|
|
property var contactsStore
|
2022-03-07 14:56:05 +00:00
|
|
|
property var emojiPopup
|
2022-01-04 12:06:05 +00:00
|
|
|
|
2021-11-26 15:37:57 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
//property int chatGroupsListViewCount: channelList.model.count
|
2021-07-20 15:22:09 +00:00
|
|
|
signal openProfileClicked()
|
2021-11-10 08:09:31 +00:00
|
|
|
signal openAppSearch()
|
2022-05-10 16:04:25 +00:00
|
|
|
signal importCommunityClicked()
|
|
|
|
signal createCommunityClicked()
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
// main layout
|
|
|
|
ColumnLayout {
|
|
|
|
anchors {
|
|
|
|
fill: parent
|
|
|
|
margins: Style.current.padding
|
2022-09-26 09:01:15 +00:00
|
|
|
bottomMargin: 0
|
2021-07-15 15:50:50 +00:00
|
|
|
}
|
2022-07-08 13:47:23 +00:00
|
|
|
spacing: Style.current.padding
|
2021-07-15 15:50:50 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
// Chat headline row
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
StatusNavigationPanelHeadline {
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
text: qsTr("Chat")
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
StatusRoundButton {
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
icon.name: "public-chat"
|
|
|
|
icon.color: Theme.palette.directColor1
|
|
|
|
icon.height: editBtn.icon.height
|
|
|
|
icon.width: editBtn.icon.width
|
|
|
|
implicitWidth: editBtn.implicitWidth
|
|
|
|
implicitHeight: editBtn.implicitHeight
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
|
|
|
|
onClicked: Global.openPopup(publicChatPopupComponent)
|
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
text: qsTr("Join public chats")
|
|
|
|
visible: parent.hovered
|
|
|
|
orientation: StatusToolTip.Orientation.Bottom
|
|
|
|
y: parent.height + 12
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusIconTabButton {
|
|
|
|
id: editBtn
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2022-07-20 12:14:50 +00:00
|
|
|
objectName: "startChatButton"
|
2022-07-08 13:47:23 +00:00
|
|
|
icon.name: "edit"
|
|
|
|
icon.color: Theme.palette.directColor1
|
|
|
|
checked: root.store.openCreateChat
|
|
|
|
highlighted: checked
|
|
|
|
onClicked: {
|
|
|
|
if (root.store.openCreateChat) {
|
|
|
|
Global.closeCreateChatView()
|
2022-07-22 11:24:28 +00:00
|
|
|
} else {
|
|
|
|
Global.openCreateChatView()
|
2022-07-08 13:47:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
text: qsTr("Start chat")
|
|
|
|
visible: parent.hovered
|
|
|
|
orientation: StatusToolTip.Orientation.Bottom
|
|
|
|
y: parent.height + 12
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
// search field
|
2022-07-22 10:28:04 +00:00
|
|
|
StatusInput {
|
2022-02-15 21:00:05 +00:00
|
|
|
id: searchInput
|
|
|
|
Layout.fillWidth: true
|
2022-07-08 13:47:23 +00:00
|
|
|
Layout.preferredHeight: 36
|
2022-07-22 10:28:04 +00:00
|
|
|
maximumHeight: 36
|
2022-04-04 11:26:30 +00:00
|
|
|
placeholderText: qsTr("Search")
|
2022-08-11 11:55:08 +00:00
|
|
|
input.asset.name: "search"
|
2022-07-08 13:47:23 +00:00
|
|
|
leftPadding: 10
|
|
|
|
topPadding: 4
|
|
|
|
bottomPadding: 4
|
2021-08-16 08:54:20 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2022-03-25 14:33:16 +00:00
|
|
|
hoverEnabled: true
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2021-11-10 08:09:31 +00:00
|
|
|
onClicked: root.openAppSearch()
|
2021-07-26 13:34:19 +00:00
|
|
|
}
|
2021-07-15 15:50:50 +00:00
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
// contact requests
|
|
|
|
StatusContactRequestsIndicatorListItem {
|
|
|
|
id: contactRequests
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: visible ? implicitHeight : 0
|
2022-06-21 08:57:09 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
readonly property int nbRequests: root.store.contactRequestsModel.count
|
2022-04-14 11:42:54 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
visible: nbRequests > 0
|
|
|
|
title: qsTr("Contact requests")
|
|
|
|
requestsCount: nbRequests
|
2021-07-26 13:34:19 +00:00
|
|
|
|
2022-08-22 14:22:28 +00:00
|
|
|
onClicked: Global.openPopup(contactRequestsPopup)
|
2021-07-26 13:34:19 +00:00
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
Item {
|
2022-07-08 13:47:23 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
clip: true
|
2022-08-17 14:48:05 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
// chat list
|
|
|
|
StatusScrollView {
|
|
|
|
id: scroll
|
2022-07-08 13:47:23 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
clip: false
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
|
|
|
|
StatusChatList {
|
|
|
|
id: channelList
|
|
|
|
objectName: "ContactsColumnView_chatList"
|
|
|
|
width: scroll.availableWidth
|
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.chatSectionModule.model
|
|
|
|
sorters: RoleSorter {
|
|
|
|
roleName: "lastMessageTimestamp"
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
}
|
2022-07-08 13:47:23 +00:00
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
highlightItem: !root.store.openCreateChat
|
|
|
|
isEnsVerified: function(pubKey) { return Utils.isEnsVerified(pubKey) }
|
|
|
|
onChatItemSelected: {
|
|
|
|
Global.closeCreateChatView()
|
|
|
|
root.chatSectionModule.setActiveItem(id, "")
|
2022-07-08 13:47:23 +00:00
|
|
|
}
|
2022-09-26 09:01:15 +00:00
|
|
|
onChatItemUnmuted: root.chatSectionModule.unmuteChat(id)
|
|
|
|
|
|
|
|
popupMenu: ChatContextMenuView {
|
|
|
|
id: chatContextMenuView
|
|
|
|
emojiPopup: root.emojiPopup
|
|
|
|
|
|
|
|
openHandler: function (id) {
|
|
|
|
let jsonObj = root.chatSectionModule.getItemAsJson(id)
|
|
|
|
let obj = JSON.parse(jsonObj)
|
|
|
|
if (obj.error) {
|
|
|
|
console.error("error parsing chat item json object, id: ", id, " error: ", obj.error)
|
|
|
|
close()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
currentFleet = root.chatSectionModule.getCurrentFleet()
|
|
|
|
isCommunityChat = root.chatSectionModule.isCommunity()
|
|
|
|
amIChatAdmin = obj.amIChatAdmin
|
|
|
|
chatId = obj.itemId
|
|
|
|
chatName = obj.name
|
|
|
|
chatDescription = obj.description
|
|
|
|
chatEmoji = obj.emoji
|
|
|
|
chatColor = obj.color
|
|
|
|
chatIcon = obj.icon
|
|
|
|
chatType = obj.type
|
|
|
|
chatMuted = obj.muted
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
onMuteChat: {
|
|
|
|
root.chatSectionModule.muteChat(chatId)
|
|
|
|
}
|
2021-12-08 11:10:34 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
onUnmuteChat: {
|
|
|
|
root.chatSectionModule.unmuteChat(chatId)
|
|
|
|
}
|
2021-12-08 13:06:31 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
onMarkAllMessagesRead: {
|
|
|
|
root.chatSectionModule.markAllMessagesRead(chatId)
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
onClearChatHistory: {
|
|
|
|
root.chatSectionModule.clearChatHistory(chatId)
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
onRequestAllHistoricMessages: {
|
|
|
|
// Not Refactored Yet - Check in the `master` branch if this is applicable here.
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
onLeaveChat: {
|
|
|
|
root.chatSectionModule.leaveChat(chatId)
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2022-09-26 09:01:15 +00:00
|
|
|
onDeleteCommunityChat: {
|
|
|
|
// Not Refactored Yet
|
|
|
|
}
|
|
|
|
|
|
|
|
onDownloadMessages: {
|
|
|
|
root.chatSectionModule.downloadMessages(chatId, file)
|
|
|
|
}
|
|
|
|
onDisplayProfilePopup: {
|
|
|
|
Global.openProfilePopup(publicKey)
|
|
|
|
}
|
|
|
|
onLeaveGroup: {
|
|
|
|
chatSectionModule.leaveChat("", chatId, true);
|
|
|
|
}
|
|
|
|
onUpdateGroupChatDetails: {
|
|
|
|
chatSectionModule.updateGroupChatDetails(
|
|
|
|
chatId,
|
|
|
|
groupName,
|
|
|
|
groupColor,
|
|
|
|
groupImage
|
|
|
|
)
|
|
|
|
}
|
2022-07-08 13:47:23 +00:00
|
|
|
}
|
2022-04-12 18:54:01 +00:00
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
2021-08-24 09:58:55 +00:00
|
|
|
}
|
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 {
|
2021-10-22 20:49:47 +00:00
|
|
|
onJoinPublicChat: {
|
2021-12-01 16:47:57 +00:00
|
|
|
chatSectionModule.createPublicChat(name)
|
2022-03-28 10:37:08 +00:00
|
|
|
close()
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
|
|
|
onSuggestedMessageClicked: {
|
2021-12-01 16:47:57 +00:00
|
|
|
chatSectionModule.createPublicChat(channel)
|
2022-03-28 10:37:08 +00:00
|
|
|
close()
|
2021-10-22 20:49:47 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 20:11:56 +00:00
|
|
|
}
|
|
|
|
|
2020-12-11 20:29:46 +00:00
|
|
|
Component {
|
|
|
|
id: privateChatPopupComponent
|
|
|
|
PrivateChatPopup {
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.store
|
2022-01-04 12:06:05 +00:00
|
|
|
contactsStore: root.contactsStore
|
2021-12-09 16:25:38 +00:00
|
|
|
onJoinPrivateChat: {
|
2022-02-15 21:00:05 +00:00
|
|
|
chatSectionModule.createOneToOneChat("", publicKey, ensName)
|
2021-12-09 16:25:38 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2021-07-20 15:22:09 +00:00
|
|
|
onProfileClicked: {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.openProfileClicked();
|
2021-07-20 15:22:09 +00:00
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communitiesPopupComponent
|
|
|
|
CommunitiesPopup {
|
2021-07-19 11:21:05 +00:00
|
|
|
anchors.centerIn: parent
|
2022-02-02 17:54:28 +00:00
|
|
|
communitiesList: root.store.communitiesList
|
2022-01-25 20:07:03 +00:00
|
|
|
onSetActiveCommunity: {
|
|
|
|
root.store.setActiveCommunity(id)
|
|
|
|
}
|
|
|
|
onSetObservedCommunity: {
|
|
|
|
root.store.setObservedCommunity(id)
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2022-05-10 16:04:25 +00:00
|
|
|
onOpenCommunityDetail: {
|
|
|
|
Global.openPopup(communityDetailPopup);
|
|
|
|
}
|
|
|
|
onImportCommunityClicked: {
|
|
|
|
root.importCommunityClicked();
|
|
|
|
}
|
|
|
|
onCreateCommunityClicked: {
|
|
|
|
root.createCommunityClicked();
|
|
|
|
}
|
2020-12-11 20:29:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityDetailPopup
|
|
|
|
CommunityDetailPopup {
|
2021-07-19 12:25:52 +00:00
|
|
|
anchors.centerIn: parent
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.store
|
2020-12-11 20:29:46 +00:00
|
|
|
onClosed: {
|
2022-05-10 16:04:25 +00:00
|
|
|
Global.openPopup(communitiesPopupComponent)
|
2020-12-11 20:29:46 +00:00
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 12:56:43 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 17:36:24 +00:00
|
|
|
Component {
|
|
|
|
id: contactRequestsPopup
|
|
|
|
ContactRequestsPopup {
|
2021-10-22 20:49:47 +00:00
|
|
|
store: root.store
|
2021-05-26 17:36:24 +00:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 19:19:34 +00:00
|
|
|
|
2022-02-02 17:54:28 +00:00
|
|
|
Connections {
|
|
|
|
target: root.store.communitiesModuleInst
|
2022-07-08 13:47:23 +00:00
|
|
|
function onImportingCommunityStateChanged(state, errorMsg) {
|
2022-05-05 10:28:54 +00:00
|
|
|
let title = ""
|
|
|
|
let loading = false
|
2022-02-02 17:54:28 +00:00
|
|
|
|
|
|
|
if (state === Constants.communityImported)
|
|
|
|
{
|
2022-04-04 11:26:30 +00:00
|
|
|
title = qsTr("Community imported")
|
2022-02-02 17:54:28 +00:00
|
|
|
}
|
|
|
|
else if (state === Constants.communityImportingInProgress)
|
|
|
|
{
|
2022-04-04 11:26:30 +00:00
|
|
|
title = qsTr("Importing community is in progress")
|
2022-05-05 10:28:54 +00:00
|
|
|
loading = true
|
2022-02-02 17:54:28 +00:00
|
|
|
}
|
|
|
|
else if (state === Constants.communityImportingError)
|
|
|
|
{
|
2022-05-05 10:28:54 +00:00
|
|
|
title = errorMsg
|
|
|
|
}
|
|
|
|
|
|
|
|
if(title == "")
|
|
|
|
{
|
|
|
|
console.error("unknown state while importing community: ", state)
|
|
|
|
return
|
2022-02-02 17:54:28 +00:00
|
|
|
}
|
|
|
|
|
2022-05-05 10:28:54 +00:00
|
|
|
Global.displayToastMessage(title,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
loading,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
"")
|
2022-02-02 17:54:28 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-09 17:35:59 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.store.mainModuleInst
|
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
function onOpenContactRequestsPopup() {
|
2022-02-09 17:35:59 +00:00
|
|
|
Global.openPopup(contactRequestsPopup)
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 19:19:34 +00:00
|
|
|
}
|