2020-06-17 15:18:31 -04:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-24 13:23:49 +10:00
|
|
|
|
2022-07-14 14:03:36 +03: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 18:04:06 +03:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-28 00:27:49 +03:00
|
|
|
import shared 1.0
|
2022-03-23 13:56:25 +03:00
|
|
|
import shared.popups 1.0
|
2021-10-01 18:58:36 +03:00
|
|
|
|
|
|
|
import "../panels"
|
|
|
|
import "../popups"
|
|
|
|
import "../popups/community"
|
2020-05-25 16:34:26 -04:00
|
|
|
|
2021-06-30 16:17:05 +02:00
|
|
|
Item {
|
2021-10-22 01:39:53 +03:00
|
|
|
id: root
|
2021-07-22 17:53:19 +03:00
|
|
|
width: 304
|
|
|
|
height: parent.height
|
|
|
|
|
2021-11-26 16:37:57 +01: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-22 01:39:53 +03:00
|
|
|
property var store
|
2022-01-04 13:06:05 +01:00
|
|
|
property var contactsStore
|
2022-03-07 09:56:05 -05:00
|
|
|
property var emojiPopup
|
2022-01-04 13:06:05 +01:00
|
|
|
|
2021-11-26 16:37:57 +01:00
|
|
|
// Not Refactored Yet
|
|
|
|
//property int chatGroupsListViewCount: channelList.model.count
|
2021-07-20 18:22:09 +03:00
|
|
|
signal openProfileClicked()
|
2021-11-10 09:09:31 +01:00
|
|
|
signal openAppSearch()
|
2022-05-10 19:04:25 +03:00
|
|
|
signal importCommunityClicked()
|
|
|
|
signal createCommunityClicked()
|
2021-06-30 16:17:05 +02:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
// main layout
|
|
|
|
ColumnLayout {
|
|
|
|
anchors {
|
|
|
|
fill: parent
|
|
|
|
margins: Style.current.padding
|
2021-07-15 18:50:50 +03:00
|
|
|
}
|
2022-07-08 15:47:23 +02:00
|
|
|
spacing: Style.current.padding
|
2021-07-15 18:50:50 +03:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
// Chat headline row
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
StatusNavigationPanelHeadline {
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
text: qsTr("Chat")
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2021-06-30 16:17:05 +02:00
|
|
|
|
2022-07-08 15:47:23 +02: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 14:14:50 +02:00
|
|
|
objectName: "startChatButton"
|
2022-07-08 15:47:23 +02: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 13:24:28 +02:00
|
|
|
} else {
|
|
|
|
Global.openCreateChatView()
|
2022-07-08 15:47:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
text: qsTr("Start chat")
|
|
|
|
visible: parent.hovered
|
|
|
|
orientation: StatusToolTip.Orientation.Bottom
|
|
|
|
y: parent.height + 12
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-15 23:00:05 +02:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
// search field
|
2022-07-22 13:28:04 +03:00
|
|
|
StatusInput {
|
2022-02-15 23:00:05 +02:00
|
|
|
id: searchInput
|
|
|
|
Layout.fillWidth: true
|
2022-07-08 15:47:23 +02:00
|
|
|
Layout.preferredHeight: 36
|
2022-07-22 13:28:04 +03:00
|
|
|
maximumHeight: 36
|
2022-04-04 13:26:30 +02:00
|
|
|
placeholderText: qsTr("Search")
|
2022-07-22 13:28:04 +03:00
|
|
|
input.icon.name: "search"
|
2022-07-08 15:47:23 +02:00
|
|
|
leftPadding: 10
|
|
|
|
topPadding: 4
|
|
|
|
bottomPadding: 4
|
2021-08-16 10:54:20 +02:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2022-03-25 15:33:16 +01:00
|
|
|
hoverEnabled: true
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2021-11-10 09:09:31 +01:00
|
|
|
onClicked: root.openAppSearch()
|
2021-07-26 15:34:19 +02:00
|
|
|
}
|
2021-07-15 18:50:50 +03:00
|
|
|
}
|
2021-06-30 16:17:05 +02:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
// contact requests
|
|
|
|
StatusContactRequestsIndicatorListItem {
|
|
|
|
id: contactRequests
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: visible ? implicitHeight : 0
|
2022-06-21 10:57:09 +02:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
readonly property int nbRequests: root.store.contactRequestsModel.count
|
2022-04-14 13:42:54 +02:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
visible: nbRequests > 0
|
|
|
|
title: qsTr("Contact requests")
|
|
|
|
requestsCount: nbRequests
|
2021-07-26 15:34:19 +02:00
|
|
|
|
2022-08-22 17:22:28 +03:00
|
|
|
onClicked: Global.openPopup(contactRequestsPopup)
|
2021-07-26 15:34:19 +02:00
|
|
|
}
|
2021-06-30 16:17:05 +02:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
// chat list
|
2022-07-13 15:29:38 +03:00
|
|
|
StatusScrollView {
|
2022-07-14 14:03:36 +03:00
|
|
|
id: scroll
|
2022-07-08 15:47:23 +02:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2021-06-30 16:17:05 +02:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
StatusChatList {
|
|
|
|
id: channelList
|
2022-07-14 14:03:36 +03:00
|
|
|
width: scroll.availableWidth
|
2022-07-08 15:47:23 +02:00
|
|
|
model: root.chatSectionModule.model
|
|
|
|
highlightItem: !root.store.openCreateChat
|
|
|
|
onChatItemSelected: {
|
|
|
|
Global.closeCreateChatView()
|
|
|
|
root.chatSectionModule.setActiveItem(id, "")
|
2021-12-09 13:53:40 +01:00
|
|
|
}
|
2022-07-08 15:47:23 +02: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
|
|
|
|
chatType = obj.type
|
|
|
|
chatMuted = obj.muted
|
|
|
|
}
|
2021-12-09 13:53:40 +01:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
onMuteChat: {
|
|
|
|
root.chatSectionModule.muteChat(chatId)
|
|
|
|
}
|
2021-12-09 13:53:40 +01:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
onUnmuteChat: {
|
|
|
|
root.chatSectionModule.unmuteChat(chatId)
|
|
|
|
}
|
2021-12-08 12:10:34 +01:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
onMarkAllMessagesRead: {
|
|
|
|
root.chatSectionModule.markAllMessagesRead(chatId)
|
|
|
|
}
|
2021-12-08 14:06:31 +01:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
onClearChatHistory: {
|
|
|
|
root.chatSectionModule.clearChatHistory(chatId)
|
|
|
|
}
|
2021-12-21 10:26:13 +01:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
onRequestAllHistoricMessages: {
|
|
|
|
// Not Refactored Yet - Check in the `master` branch if this is applicable here.
|
|
|
|
}
|
2021-12-21 10:26:13 +01:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
onLeaveChat: {
|
|
|
|
root.chatSectionModule.leaveChat(chatId)
|
|
|
|
}
|
2021-12-21 10:26:13 +01:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
onDeleteCommunityChat: {
|
|
|
|
// Not Refactored Yet
|
|
|
|
}
|
2021-12-21 10:26:13 +01:00
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
onDownloadMessages: {
|
|
|
|
root.chatSectionModule.downloadMessages(chatId, file)
|
|
|
|
}
|
|
|
|
onDisplayProfilePopup: {
|
|
|
|
Global.openProfilePopup(publicKey)
|
|
|
|
}
|
|
|
|
onLeaveGroup: {
|
|
|
|
chatSectionModule.leaveChat("", chatId, true);
|
|
|
|
}
|
|
|
|
onDisplayGroupInfoPopup: {
|
|
|
|
chatSectionModule.prepareChatContentModuleForChatId(chatId)
|
|
|
|
let chatContentModule = chatSectionModule.getChatContentModule()
|
2022-05-10 19:04:25 +03:00
|
|
|
Global.openPopup(root.store.groupInfoPopupComponent, {
|
2022-07-08 15:47:23 +02:00
|
|
|
chatContentModule: chatContentModule,
|
|
|
|
chatDetails: chatContentModule.chatDetails
|
|
|
|
})
|
|
|
|
}
|
2022-07-12 10:27:35 +02:00
|
|
|
onUpdateGroupChatDetails: {
|
|
|
|
chatSectionModule.updateGroupChatDetails(
|
|
|
|
chatId,
|
|
|
|
groupName,
|
|
|
|
groupColor,
|
|
|
|
groupImage
|
|
|
|
)
|
2022-07-08 15:47:23 +02:00
|
|
|
}
|
2022-04-12 14:54:01 -04:00
|
|
|
}
|
2021-06-30 16:17:05 +02:00
|
|
|
}
|
2021-08-24 12:58:55 +03:00
|
|
|
}
|
2020-05-27 14:40:58 -04:00
|
|
|
}
|
2020-05-25 16:34:26 -04:00
|
|
|
|
2020-12-11 15:29:46 -05:00
|
|
|
Component {
|
|
|
|
id: publicChatPopupComponent
|
|
|
|
PublicChatPopup {
|
2021-10-22 23:49:47 +03:00
|
|
|
onJoinPublicChat: {
|
2021-12-01 17:47:57 +01:00
|
|
|
chatSectionModule.createPublicChat(name)
|
2022-03-28 13:37:08 +03:00
|
|
|
close()
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
|
|
|
onSuggestedMessageClicked: {
|
2021-12-01 17:47:57 +01:00
|
|
|
chatSectionModule.createPublicChat(channel)
|
2022-03-28 13:37:08 +03:00
|
|
|
close()
|
2021-10-22 23:49:47 +03:00
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-05-27 16:11:56 -04:00
|
|
|
}
|
|
|
|
|
2020-12-11 15:29:46 -05:00
|
|
|
Component {
|
|
|
|
id: privateChatPopupComponent
|
|
|
|
PrivateChatPopup {
|
2021-10-22 23:49:47 +03:00
|
|
|
store: root.store
|
2022-01-04 13:06:05 +01:00
|
|
|
contactsStore: root.contactsStore
|
2021-12-09 11:25:38 -05:00
|
|
|
onJoinPrivateChat: {
|
2022-02-15 23:00:05 +02:00
|
|
|
chatSectionModule.createOneToOneChat("", publicKey, ensName)
|
2021-12-09 11:25:38 -05:00
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2021-07-20 18:22:09 +03:00
|
|
|
onProfileClicked: {
|
2021-10-22 01:39:53 +03:00
|
|
|
root.openProfileClicked();
|
2021-07-20 18:22:09 +03:00
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communitiesPopupComponent
|
|
|
|
CommunitiesPopup {
|
2021-07-19 13:21:05 +02:00
|
|
|
anchors.centerIn: parent
|
2022-02-02 18:54:28 +01:00
|
|
|
communitiesList: root.store.communitiesList
|
2022-01-25 15:07:03 -05:00
|
|
|
onSetActiveCommunity: {
|
|
|
|
root.store.setActiveCommunity(id)
|
|
|
|
}
|
|
|
|
onSetObservedCommunity: {
|
|
|
|
root.store.setObservedCommunity(id)
|
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
2022-05-10 19:04:25 +03:00
|
|
|
onOpenCommunityDetail: {
|
|
|
|
Global.openPopup(communityDetailPopup);
|
|
|
|
}
|
|
|
|
onImportCommunityClicked: {
|
|
|
|
root.importCommunityClicked();
|
|
|
|
}
|
|
|
|
onCreateCommunityClicked: {
|
|
|
|
root.createCommunityClicked();
|
|
|
|
}
|
2020-12-11 15:29:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: communityDetailPopup
|
|
|
|
CommunityDetailPopup {
|
2021-07-19 14:25:52 +02:00
|
|
|
anchors.centerIn: parent
|
2021-10-22 23:49:47 +03:00
|
|
|
store: root.store
|
2020-12-11 15:29:46 -05:00
|
|
|
onClosed: {
|
2022-05-10 19:04:25 +03:00
|
|
|
Global.openPopup(communitiesPopupComponent)
|
2020-12-11 15:29:46 -05:00
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 08:56:43 -04:00
|
|
|
}
|
|
|
|
|
2021-05-26 13:36:24 -04:00
|
|
|
Component {
|
|
|
|
id: contactRequestsPopup
|
|
|
|
ContactRequestsPopup {
|
2021-10-22 23:49:47 +03:00
|
|
|
store: root.store
|
2021-05-26 13:36:24 -04:00
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 15:19:34 -04:00
|
|
|
|
2022-02-02 18:54:28 +01:00
|
|
|
Connections {
|
|
|
|
target: root.store.communitiesModuleInst
|
2022-07-08 15:47:23 +02:00
|
|
|
function onImportingCommunityStateChanged(state, errorMsg) {
|
2022-05-05 12:28:54 +02:00
|
|
|
let title = ""
|
|
|
|
let loading = false
|
2022-02-02 18:54:28 +01:00
|
|
|
|
|
|
|
if (state === Constants.communityImported)
|
|
|
|
{
|
2022-04-04 13:26:30 +02:00
|
|
|
title = qsTr("Community imported")
|
2022-02-02 18:54:28 +01:00
|
|
|
}
|
|
|
|
else if (state === Constants.communityImportingInProgress)
|
|
|
|
{
|
2022-04-04 13:26:30 +02:00
|
|
|
title = qsTr("Importing community is in progress")
|
2022-05-05 12:28:54 +02:00
|
|
|
loading = true
|
2022-02-02 18:54:28 +01:00
|
|
|
}
|
|
|
|
else if (state === Constants.communityImportingError)
|
|
|
|
{
|
2022-05-05 12:28:54 +02:00
|
|
|
title = errorMsg
|
|
|
|
}
|
|
|
|
|
|
|
|
if(title == "")
|
|
|
|
{
|
|
|
|
console.error("unknown state while importing community: ", state)
|
|
|
|
return
|
2022-02-02 18:54:28 +01:00
|
|
|
}
|
|
|
|
|
2022-05-05 12:28:54 +02:00
|
|
|
Global.displayToastMessage(title,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
loading,
|
|
|
|
Constants.ephemeralNotificationType.normal,
|
|
|
|
"")
|
2022-02-02 18:54:28 +01:00
|
|
|
}
|
|
|
|
}
|
2022-02-09 18:35:59 +01:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.store.mainModuleInst
|
|
|
|
|
2022-07-08 15:47:23 +02:00
|
|
|
function onOpenContactRequestsPopup() {
|
2022-02-09 18:35:59 +01:00
|
|
|
Global.openPopup(contactRequestsPopup)
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 15:19:34 -04:00
|
|
|
}
|