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
|
2023-05-02 09:37:12 +00:00
|
|
|
import shared.controls 1.0
|
2022-03-23 10:56:25 +00:00
|
|
|
import shared.popups 1.0
|
2023-06-23 06:17:04 +00:00
|
|
|
import shared.views.chat 1.0
|
|
|
|
import shared.panels 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"
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0
|
2023-06-23 06:17:04 +00:00
|
|
|
import AppLayouts.Communities.popups 1.0
|
2024-05-22 08:13:39 +00:00
|
|
|
import AppLayouts.Profile.stores 1.0
|
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
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
property RootStore store
|
|
|
|
property ContactsStore contactsStore
|
2022-03-07 14:56:05 +00:00
|
|
|
property var emojiPopup
|
2022-01-04 12:06:05 +00:00
|
|
|
|
2021-07-20 15:22:09 +00:00
|
|
|
signal openProfileClicked()
|
2021-11-10 08:09:31 +00:00
|
|
|
signal openAppSearch()
|
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
|
2022-10-10 10:30:30 +00:00
|
|
|
topMargin: Style.current.smallPadding
|
2021-07-15 15:50:50 +00:00
|
|
|
}
|
2023-05-02 09:37:12 +00:00
|
|
|
spacing: Style.current.halfPadding
|
2021-07-15 15:50:50 +00:00
|
|
|
|
2022-07-08 13:47:23 +00:00
|
|
|
// Chat headline row
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
2023-05-02 09:37:12 +00:00
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
2022-07-08 13:47:23 +00:00
|
|
|
|
|
|
|
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
|
2023-05-02 09:37:12 +00:00
|
|
|
SearchBox {
|
2022-02-15 21:00:05 +00:00
|
|
|
id: searchInput
|
|
|
|
Layout.fillWidth: true
|
2023-05-02 09:37:12 +00:00
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
2022-07-08 13:47:23 +00:00
|
|
|
Layout.preferredHeight: 36
|
2022-07-22 10:28:04 +00:00
|
|
|
maximumHeight: 36
|
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
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
ChatsLoadingPanel {
|
2022-07-08 13:47:23 +00:00
|
|
|
Layout.fillWidth: true
|
2023-05-02 09:37:12 +00:00
|
|
|
chatSectionModule: root.chatSectionModule
|
|
|
|
}
|
2022-08-17 14:48:05 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
// chat list
|
|
|
|
StatusScrollView {
|
2023-05-31 20:58:23 +00:00
|
|
|
id: scrollView
|
2023-05-02 09:37:12 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2023-05-31 20:58:23 +00:00
|
|
|
contentWidth: availableWidth
|
2023-03-16 19:05:05 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
StatusChatList {
|
|
|
|
id: channelList
|
|
|
|
objectName: "ContactsColumnView_chatList"
|
2023-05-31 20:58:23 +00:00
|
|
|
width: scrollView.availableWidth
|
2023-05-02 09:37:12 +00:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.chatSectionModule.model
|
|
|
|
sorters: RoleSorter {
|
|
|
|
roleName: "lastMessageTimestamp"
|
|
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
}
|
|
|
|
}
|
2022-07-08 13:47:23 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
highlightItem: !root.store.openCreateChat
|
|
|
|
isEnsVerified: function(pubKey) { return Utils.isEnsVerified(pubKey) }
|
|
|
|
onChatItemSelected: {
|
|
|
|
Global.closeCreateChatView()
|
|
|
|
root.chatSectionModule.setActiveItem(id, "")
|
|
|
|
}
|
|
|
|
onChatItemUnmuted: root.chatSectionModule.unmuteChat(id)
|
|
|
|
|
|
|
|
popupMenu: ChatContextMenuView {
|
|
|
|
id: chatContextMenuView
|
2024-02-07 12:38:46 +00:00
|
|
|
showDebugOptions: root.store.isDebugEnabled
|
2023-05-02 09:37:12 +00:00
|
|
|
|
|
|
|
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
|
2022-09-26 09:01:15 +00:00
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
currentFleet = root.chatSectionModule.getCurrentFleet()
|
|
|
|
isCommunityChat = root.chatSectionModule.isCommunity()
|
2023-08-22 18:09:34 +00:00
|
|
|
amIChatAdmin = obj.memberRole === Constants.memberRole.owner ||
|
|
|
|
obj.memberRole === Constants.memberRole.admin ||
|
|
|
|
obj.memberRole === Constants.memberRole.tokenMaster
|
2023-05-02 09:37:12 +00:00
|
|
|
chatId = obj.itemId
|
|
|
|
chatName = obj.name
|
|
|
|
chatDescription = obj.description
|
|
|
|
chatEmoji = obj.emoji
|
|
|
|
chatColor = obj.color
|
|
|
|
chatIcon = obj.icon
|
|
|
|
chatType = obj.type
|
|
|
|
chatMuted = obj.muted
|
2022-07-08 13:47:23 +00:00
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
onMuteChat: {
|
2023-05-26 12:54:10 +00:00
|
|
|
root.chatSectionModule.muteChat(chatId, interval)
|
2023-05-02 09:37:12 +00:00
|
|
|
}
|
2021-12-08 11:10:34 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
onUnmuteChat: {
|
|
|
|
root.chatSectionModule.unmuteChat(chatId)
|
|
|
|
}
|
2021-12-08 13:06:31 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
onMarkAllMessagesRead: {
|
|
|
|
root.chatSectionModule.markAllMessagesRead(chatId)
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2023-11-29 09:55:03 +00:00
|
|
|
onRequestMoreMessages: {
|
|
|
|
root.chatSectionModule.requestMoreMessages(chatId)
|
|
|
|
}
|
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
onClearChatHistory: {
|
|
|
|
root.chatSectionModule.clearChatHistory(chatId)
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
onRequestAllHistoricMessages: {
|
|
|
|
// Not Refactored Yet - Check in the `master` branch if this is applicable here.
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
onLeaveChat: {
|
|
|
|
root.chatSectionModule.leaveChat(chatId)
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
onDeleteCommunityChat: {
|
|
|
|
// Not Refactored Yet
|
|
|
|
}
|
2022-09-26 09:01:15 +00:00
|
|
|
|
2023-05-02 09:37:12 +00:00
|
|
|
onDownloadMessages: {
|
|
|
|
root.chatSectionModule.downloadMessages(chatId, file)
|
|
|
|
}
|
|
|
|
onDisplayProfilePopup: {
|
|
|
|
Global.openProfilePopup(publicKey)
|
|
|
|
}
|
|
|
|
onUpdateGroupChatDetails: {
|
|
|
|
chatSectionModule.updateGroupChatDetails(
|
|
|
|
chatId,
|
|
|
|
groupName,
|
|
|
|
groupColor,
|
|
|
|
groupImage
|
|
|
|
)
|
|
|
|
}
|
|
|
|
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-07-08 19:19:34 +00:00
|
|
|
}
|