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
|
2023-01-30 21:05:34 +00:00
|
|
|
width: Constants.chatSectionLeftColumnWidth
|
2021-07-22 14:53:19 +00:00
|
|
|
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()
|
2023-01-17 17:13:03 +00:00
|
|
|
signal addRemoveGroupMemberClicked()
|
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-10-10 10:30:30 +00:00
|
|
|
topMargin: Style.current.smallPadding
|
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 {
|
2022-12-26 16:31:26 +00:00
|
|
|
objectName: "ContactsColumnView_MessagesHeadline"
|
2022-07-08 13:47:23 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2022-11-29 11:12:30 +00:00
|
|
|
text: qsTr("Messages")
|
2022-07-08 13:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
StatusIconTabButton {
|
2023-01-09 19:57:53 +00:00
|
|
|
id: startChatButton
|
2022-07-08 13:47:23 +00:00
|
|
|
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-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
|
2022-10-10 12:58:58 +00:00
|
|
|
padding: 0
|
2022-09-26 09:01:15 +00:00
|
|
|
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
|
|
|
|
)
|
|
|
|
}
|
2023-01-17 17:13:03 +00:00
|
|
|
onAddRemoveGroupMember: {
|
|
|
|
root.addRemoveGroupMemberClicked()
|
|
|
|
}
|
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: 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
|
|
|
}
|
|
|
|
|
2022-02-02 17:54:28 +00:00
|
|
|
Connections {
|
2022-11-28 14:57:56 +00:00
|
|
|
target: root.store
|
2023-01-18 12:49:04 +00:00
|
|
|
|
2022-11-28 14:57:56 +00:00
|
|
|
function onImportingCommunityStateChanged(communityId, state, errorMsg) {
|
2023-01-18 12:49:04 +00:00
|
|
|
|
|
|
|
const community = root.store.getCommunityDetailsAsJson(communityId)
|
2022-05-05 10:28:54 +00:00
|
|
|
let title = ""
|
2023-01-18 12:49:04 +00:00
|
|
|
let subTitle = ""
|
2022-05-05 10:28:54 +00:00
|
|
|
let loading = false
|
2022-02-02 17:54:28 +00:00
|
|
|
|
2023-01-18 12:49:04 +00:00
|
|
|
switch (state)
|
2022-02-02 17:54:28 +00:00
|
|
|
{
|
2023-01-18 12:49:04 +00:00
|
|
|
case Constants.communityImported:
|
|
|
|
title = qsTr("'%1' community imported").arg(community.name);
|
|
|
|
break
|
|
|
|
case 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
|
2023-01-18 12:49:04 +00:00
|
|
|
break
|
|
|
|
case Constants.communityImportingError:
|
|
|
|
title = qsTr("Failed to import community '%1'").arg(community.name)
|
|
|
|
subTitle = errorMsg
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
console.error("unknown state while importing community: %1").arg(state)
|
2022-05-05 10:28:54 +00:00
|
|
|
return
|
2022-02-02 17:54:28 +00:00
|
|
|
}
|
|
|
|
|
2022-05-05 10:28:54 +00:00
|
|
|
Global.displayToastMessage(title,
|
2023-01-18 12:49:04 +00:00
|
|
|
subTitle,
|
2022-05-05 10:28:54 +00:00
|
|
|
"",
|
|
|
|
loading,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
"")
|
2022-02-02 17:54:28 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-08 19:19:34 +00:00
|
|
|
}
|