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
|
|
|
|
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
|
|
|
|
|
|
|
import "../panels"
|
|
|
|
import "../popups"
|
|
|
|
import "../popups/community"
|
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
|
2021-07-26 13:34:19 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2021-06-30 14:17:05 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
|
|
|
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()
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-08-18 14:43:59 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
appMain.openContactsPopup.connect(function(){
|
2021-12-09 16:25:38 +00:00
|
|
|
Global.openPopup(contactRequestsPopup, {chatSectionModule})
|
2021-08-18 14:43:59 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-07-15 15:50:50 +00:00
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
//steal focus from search field
|
2021-07-26 13:34:19 +00:00
|
|
|
actionButton.forceActiveFocus();
|
2021-07-15 15:50:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Chat")
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
RowLayout {
|
2021-07-26 13:34:19 +00:00
|
|
|
id: searchInputWrapper
|
2022-05-17 15:20:41 +00:00
|
|
|
width: 288
|
2021-07-26 13:34:19 +00:00
|
|
|
height: searchInput.height
|
2022-02-15 21:00:05 +00:00
|
|
|
anchors.top: headline.bottom
|
|
|
|
anchors.topMargin: 16
|
2022-05-17 15:20:41 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2022-02-15 21:00:05 +00:00
|
|
|
|
|
|
|
StatusBaseInput {
|
|
|
|
id: searchInput
|
|
|
|
Layout.fillWidth: true
|
2022-05-17 15:20:41 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2022-02-15 21:00:05 +00:00
|
|
|
implicitHeight: 36
|
|
|
|
topPadding: 9
|
2022-04-04 11:26:30 +00:00
|
|
|
placeholderText: qsTr("Search")
|
2022-02-15 21:00:05 +00:00
|
|
|
icon.name: "search"
|
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-06-21 08:57:09 +00:00
|
|
|
StatusRoundButton {
|
2022-02-15 21:00:05 +00:00
|
|
|
icon.name: "public-chat"
|
2022-06-21 08:57:09 +00:00
|
|
|
icon.height: editBtn.icon.height
|
|
|
|
icon.width: editBtn.icon.width
|
|
|
|
implicitWidth: editBtn.implicitWidth
|
|
|
|
implicitHeight: editBtn.implicitHeight
|
|
|
|
type: StatusRoundButton.Type.Tertiary
|
|
|
|
|
|
|
|
onClicked: { Global.openPopup(publicChatPopupComponent) }
|
2022-04-14 11:42:54 +00:00
|
|
|
|
|
|
|
StatusToolTip {
|
2022-06-21 08:57:09 +00:00
|
|
|
text: qsTr("Join public chats")
|
2022-04-14 11:42:54 +00:00
|
|
|
visible: parent.hovered
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
}
|
2021-07-26 13:34:19 +00:00
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
StatusIconTabButton {
|
2022-06-21 08:57:09 +00:00
|
|
|
id: editBtn
|
2022-02-15 21:00:05 +00:00
|
|
|
icon.name: "edit"
|
2022-03-28 21:43:04 +00:00
|
|
|
checked: root.store.openCreateChat
|
2022-04-14 11:42:54 +00:00
|
|
|
highlighted: root.store.openCreateChat
|
2022-02-15 21:00:05 +00:00
|
|
|
onClicked: {
|
|
|
|
root.store.openCreateChat = !root.store.openCreateChat;
|
2022-05-13 15:27:26 +00:00
|
|
|
if (!root.store.openCreateChat) {
|
|
|
|
Global.closeCreateChatView()
|
|
|
|
} else {
|
|
|
|
Global.openCreateChatView()
|
|
|
|
}
|
2021-07-26 13:34:19 +00:00
|
|
|
}
|
2022-04-14 11:42:54 +00:00
|
|
|
|
|
|
|
StatusToolTip {
|
|
|
|
text: qsTr("Start chat")
|
|
|
|
visible: parent.hovered
|
|
|
|
}
|
2021-07-26 13:34:19 +00:00
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
|
2021-06-30 14:17:05 +00:00
|
|
|
StatusContactRequestsIndicatorListItem {
|
|
|
|
id: contactRequests
|
|
|
|
|
2022-01-04 12:06:05 +00:00
|
|
|
property int nbRequests: root.store.contactRequestsModel.count
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-07-26 13:34:19 +00:00
|
|
|
anchors.top: searchInputWrapper.bottom
|
2021-06-30 14:17:05 +00:00
|
|
|
anchors.topMargin: visible ? Style.current.padding : 0
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
visible: nbRequests > 0
|
|
|
|
height: visible ? implicitHeight : 0
|
|
|
|
|
2022-04-04 11:26:30 +00:00
|
|
|
title: qsTr("Contact requests")
|
2021-06-30 14:17:05 +00:00
|
|
|
requestsCount: nbRequests
|
|
|
|
|
2021-12-07 20:33:12 +00:00
|
|
|
sensor.onClicked: Global.openPopup(contactRequestsPopup)
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-10-21 22:39:53 +00:00
|
|
|
anchors.bottom: root.bottom
|
2021-08-24 09:58:55 +00:00
|
|
|
contentHeight: channelList.childrenRect.height + emptyViewAndSuggestions.childrenRect.height
|
2021-06-30 14:17:05 +00:00
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
StatusChatList {
|
|
|
|
id: channelList
|
2022-05-17 15:20:41 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-11-26 15:37:57 +00:00
|
|
|
model: root.chatSectionModule.model
|
2022-05-04 14:11:59 +00:00
|
|
|
highlightItem: !root.store.openCreateChat
|
2022-02-15 21:00:05 +00:00
|
|
|
onChatItemSelected: {
|
|
|
|
root.chatSectionModule.setActiveItem(id, "")
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
onChatItemUnmuted: root.chatSectionModule.unmuteChat(id)
|
2021-06-30 14:17:05 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
popupMenu: ChatContextMenuView {
|
2021-11-03 19:35:12 +00:00
|
|
|
id: chatContextMenuView
|
2022-03-07 14:56:05 +00:00
|
|
|
emojiPopup: root.emojiPopup
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-06-30 14:17:05 +00:00
|
|
|
openHandler: function (id) {
|
2021-12-09 12:53:40 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-12-21 09:26:13 +00:00
|
|
|
currentFleet = root.chatSectionModule.getCurrentFleet()
|
2021-12-09 12:53:40 +00:00
|
|
|
isCommunityChat = root.chatSectionModule.isCommunity()
|
2022-01-05 15:50:03 +00:00
|
|
|
amIChatAdmin = obj.amIChatAdmin
|
2021-12-09 12:53:40 +00:00
|
|
|
chatId = obj.itemId
|
|
|
|
chatName = obj.name
|
2021-12-21 09:26:13 +00:00
|
|
|
chatDescription = obj.description
|
2022-03-07 14:56:05 +00:00
|
|
|
chatEmoji = obj.emoji
|
2022-03-10 19:28:37 +00:00
|
|
|
chatColor = obj.color
|
2021-12-09 12:53:40 +00:00
|
|
|
chatType = obj.type
|
|
|
|
chatMuted = obj.muted
|
|
|
|
}
|
|
|
|
|
|
|
|
onMuteChat: {
|
2021-12-21 09:26:13 +00:00
|
|
|
root.chatSectionModule.muteChat(chatId)
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onUnmuteChat: {
|
2021-12-21 09:26:13 +00:00
|
|
|
root.chatSectionModule.unmuteChat(chatId)
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
2021-12-08 11:10:34 +00:00
|
|
|
|
|
|
|
onMarkAllMessagesRead: {
|
2021-12-21 09:26:13 +00:00
|
|
|
root.chatSectionModule.markAllMessagesRead(chatId)
|
2021-12-08 11:10:34 +00:00
|
|
|
}
|
2021-12-08 13:06:31 +00:00
|
|
|
|
|
|
|
onClearChatHistory: {
|
2021-12-21 09:26:13 +00:00
|
|
|
root.chatSectionModule.clearChatHistory(chatId)
|
|
|
|
}
|
|
|
|
|
|
|
|
onRequestAllHistoricMessages: {
|
|
|
|
// Not Refactored Yet - Check in the `master` branch if this is applicable here.
|
|
|
|
}
|
|
|
|
|
|
|
|
onLeaveChat: {
|
|
|
|
root.chatSectionModule.leaveChat(chatId)
|
|
|
|
}
|
|
|
|
|
2022-01-25 12:09:27 +00:00
|
|
|
onDeleteCommunityChat: {
|
2021-12-21 09:26:13 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
}
|
|
|
|
|
|
|
|
onDownloadMessages: {
|
2022-06-22 07:43:30 +00:00
|
|
|
root.chatSectionModule.downloadMessages(chatId, file)
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onDisplayProfilePopup: {
|
2022-01-05 15:50:03 +00:00
|
|
|
Global.openProfilePopup(publicKey)
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
onLeaveGroup: {
|
|
|
|
chatSectionModule.leaveChat("", chatId, true);
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
onDisplayGroupInfoPopup: {
|
2022-01-31 13:18:51 +00:00
|
|
|
chatSectionModule.prepareChatContentModuleForChatId(chatId)
|
|
|
|
let chatContentModule = chatSectionModule.getChatContentModule()
|
|
|
|
Global.openPopup(groupInfoPopupComponent, {
|
2022-02-14 12:18:25 +00:00
|
|
|
chatContentModule: chatContentModule,
|
|
|
|
chatDetails: chatContentModule.chatDetails
|
2022-01-31 13:18:51 +00:00
|
|
|
})
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
2022-04-12 18:54:01 +00:00
|
|
|
onRenameGroupChat: {
|
|
|
|
chatSectionModule.renameGroupChat(
|
|
|
|
chatId,
|
|
|
|
groupName
|
|
|
|
)
|
|
|
|
}
|
2021-06-30 14:17:05 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-24 09:58:55 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
EmptyViewPanel {
|
2021-08-24 09:58:55 +00:00
|
|
|
id: emptyViewAndSuggestions
|
2021-10-20 09:50:50 +00:00
|
|
|
visible: !localAccountSensitiveSettings.hideChannelSuggestions
|
2021-08-24 09:58:55 +00:00
|
|
|
width: parent.width
|
|
|
|
anchors.top: channelList.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
2022-01-28 08:19:49 +00:00
|
|
|
rootStore: root.store
|
2021-12-01 16:47:57 +00:00
|
|
|
onSuggestedMessageClicked: chatSectionModule.createPublicChat(channel)
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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: {
|
|
|
|
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
|
|
|
|
onImportingCommunityStateChanged: {
|
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
|
|
|
|
|
|
|
|
onOpenContactRequestsPopup:{
|
|
|
|
Global.openPopup(contactRequestsPopup)
|
|
|
|
}
|
|
|
|
}
|
2020-07-08 19:19:34 +00:00
|
|
|
}
|