2021-12-09 12:53:40 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import Qt.labs.platform 1.1
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-03-07 14:56:05 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2021-12-09 12:53:40 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
|
|
|
import shared.controls 1.0
|
|
|
|
import shared.views.chat 1.0
|
|
|
|
|
|
|
|
import "../helpers"
|
|
|
|
import "../controls"
|
|
|
|
import "../popups"
|
|
|
|
import "../panels"
|
|
|
|
import "../../Wallet"
|
|
|
|
import "../stores"
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: chatContentRoot
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
// Important:
|
|
|
|
// Each chat/channel has its own ChatContentModule
|
|
|
|
property var chatContentModule
|
2021-12-22 14:55:13 +00:00
|
|
|
property var rootStore
|
2022-01-04 12:06:05 +00:00
|
|
|
property var contactsStore
|
2022-02-28 20:14:04 +00:00
|
|
|
property bool isActiveChannel: false
|
2022-03-07 14:56:05 +00:00
|
|
|
property var emojiPopup
|
2022-02-15 21:00:05 +00:00
|
|
|
property alias textInputField: chatInput
|
2022-02-08 12:08:02 +00:00
|
|
|
property UsersStore usersStore: UsersStore {}
|
|
|
|
|
|
|
|
onChatContentModuleChanged: {
|
|
|
|
chatContentRoot.usersStore.usersModule = chatContentRoot.chatContentModule.usersModule
|
|
|
|
}
|
|
|
|
|
2022-02-14 23:27:23 +00:00
|
|
|
signal openStickerPackPopup(string stickerPackId)
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-12-23 20:46:58 +00:00
|
|
|
property Component sendTransactionNoEnsModal
|
|
|
|
property Component receiveTransactionModal
|
|
|
|
property Component sendTransactionWithEnsModal
|
|
|
|
|
2022-02-04 10:21:05 +00:00
|
|
|
property bool isBlocked: false
|
|
|
|
|
2022-01-05 15:50:03 +00:00
|
|
|
property bool stickersLoaded: false
|
|
|
|
|
2022-01-27 17:14:21 +00:00
|
|
|
// NOTE: Used this property change as it is the current way used for displaying new channel/chat data of content view.
|
|
|
|
// If in the future content is loaded dynamically, input focus should be activated when loaded / created content view.
|
|
|
|
onHeightChanged: {
|
|
|
|
if(chatContentRoot.height > 0) {
|
|
|
|
chatInput.forceInputActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
StatusChatToolBar {
|
|
|
|
id: topBar
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
2022-01-11 23:16:17 +00:00
|
|
|
chatInfoButton.title: chatContentModule? chatContentModule.chatDetails.name : ""
|
2021-12-09 12:53:40 +00:00
|
|
|
chatInfoButton.subTitle: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule)
|
|
|
|
return ""
|
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// In some moment in future this should be part of the backend logic.
|
|
|
|
// (once we add transaltion on the backend side)
|
|
|
|
switch (chatContentModule.chatDetails.type) {
|
|
|
|
case Constants.chatType.oneToOne:
|
|
|
|
return (chatContentModule.isMyContact(chatContentModule.chatDetails.id) ?
|
|
|
|
//% "Contact"
|
|
|
|
qsTrId("chat-is-a-contact") :
|
|
|
|
//% "Not a contact"
|
|
|
|
qsTrId("chat-is-not-a-contact"))
|
|
|
|
case Constants.chatType.publicChat:
|
|
|
|
//% "Public chat"
|
|
|
|
return qsTrId("public-chat")
|
|
|
|
case Constants.chatType.privateGroupChat:
|
2022-02-17 18:18:05 +00:00
|
|
|
let cnt = chatContentRoot.usersStore.usersModule.model.count
|
2021-12-09 12:53:40 +00:00
|
|
|
//% "%1 members"
|
|
|
|
if(cnt > 1) return qsTrId("-1-members").arg(cnt);
|
|
|
|
//% "1 member"
|
|
|
|
return qsTrId("1-member");
|
|
|
|
case Constants.chatType.communityChat:
|
|
|
|
return Utils.linkifyAndXSS(chatContentModule.chatDetails.description).trim()
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
2022-01-11 23:16:17 +00:00
|
|
|
chatInfoButton.image.source: chatContentModule? chatContentModule.chatDetails.icon : ""
|
2022-04-01 11:46:32 +00:00
|
|
|
chatInfoButton.ringSettings.ringSpecModel: chatContentModule && chatContentModule.chatDetails.type === Constants.chatType.oneToOne ?
|
|
|
|
Utils.getColorHashAsJson(chatContentModule.chatDetails.id) : ""
|
2022-04-07 19:05:33 +00:00
|
|
|
chatInfoButton.icon.color: chatContentModule?
|
|
|
|
chatContentModule.chatDetails.type === Constants.chatType.oneToOne ?
|
|
|
|
Utils.colorForPubkey(chatContentModule.chatDetails.id)
|
|
|
|
: chatContentModule.chatDetails.color
|
|
|
|
: ""
|
2022-03-14 19:32:52 +00:00
|
|
|
chatInfoButton.icon.emoji: chatContentModule? chatContentModule.chatDetails.emoji : ""
|
|
|
|
chatInfoButton.icon.emojiSize: "24x24"
|
2022-01-11 23:16:17 +00:00
|
|
|
chatInfoButton.type: chatContentModule? chatContentModule.chatDetails.type : Constants.chatType.unknown
|
|
|
|
chatInfoButton.pinnedMessagesCount: chatContentModule? chatContentModule.pinnedMessagesModel.count : 0
|
|
|
|
chatInfoButton.muted: chatContentModule? chatContentModule.chatDetails.muted : false
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-12-17 12:53:10 +00:00
|
|
|
chatInfoButton.onPinnedMessagesCountClicked: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on open pinned messages - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2021-12-17 12:53:10 +00:00
|
|
|
Global.openPopup(pinnedMessagesPopupComponent, {
|
2022-01-19 15:59:08 +00:00
|
|
|
store: rootStore,
|
2022-01-12 12:55:26 +00:00
|
|
|
messageStore: messageStore,
|
|
|
|
pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
|
|
|
|
messageToPin: ""
|
|
|
|
})
|
2021-12-17 12:53:10 +00:00
|
|
|
}
|
2022-01-11 23:16:17 +00:00
|
|
|
chatInfoButton.onUnmute: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on unmute chat - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatContentModule.unmuteChat()
|
|
|
|
}
|
|
|
|
|
|
|
|
chatInfoButton.sensor.enabled: {
|
|
|
|
if(!chatContentModule)
|
|
|
|
return false
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2022-01-11 23:16:17 +00:00
|
|
|
return chatContentModule.chatDetails.type !== Constants.chatType.publicChat &&
|
|
|
|
chatContentModule.chatDetails.type !== Constants.chatType.communityChat
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
chatInfoButton.onClicked: {
|
2022-01-18 15:56:57 +00:00
|
|
|
switch (chatContentModule.chatDetails.type) {
|
|
|
|
case Constants.chatType.privateGroupChat:
|
2021-12-08 12:31:28 +00:00
|
|
|
Global.openPopup(groupInfoPopupComponent, {
|
2022-02-14 12:18:25 +00:00
|
|
|
chatContentModule: chatContentModule,
|
|
|
|
chatDetails: chatContentModule.chatDetails
|
|
|
|
})
|
2022-01-18 15:56:57 +00:00
|
|
|
break;
|
|
|
|
case Constants.chatType.oneToOne:
|
|
|
|
Global.openProfilePopup(chatContentModule.chatDetails.id)
|
|
|
|
break;
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 23:16:17 +00:00
|
|
|
membersButton.visible: {
|
2022-03-11 18:50:22 +00:00
|
|
|
if(!chatContentModule || chatContentModule.chatDetails.type === Constants.chatType.publicChat)
|
2022-01-11 23:16:17 +00:00
|
|
|
return false
|
|
|
|
|
|
|
|
return localAccountSensitiveSettings.showOnlineUsers &&
|
|
|
|
chatContentModule.chatDetails.isUsersListAvailable
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
membersButton.highlighted: localAccountSensitiveSettings.expandUsersList
|
|
|
|
notificationButton.visible: localAccountSensitiveSettings.isActivityCenterEnabled
|
|
|
|
notificationButton.tooltip.offset: localAccountSensitiveSettings.expandUsersList ? 0 : 14
|
|
|
|
|
2022-01-11 23:16:17 +00:00
|
|
|
notificationCount: {
|
|
|
|
if(!chatContentModule)
|
|
|
|
return 0
|
|
|
|
|
|
|
|
return chatContentModule.chatDetails.notificationCount
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
onSearchButtonClicked: root.openAppSearch()
|
|
|
|
|
|
|
|
onMembersButtonClicked: localAccountSensitiveSettings.expandUsersList = !localAccountSensitiveSettings.expandUsersList
|
|
|
|
onNotificationButtonClicked: activityCenter.open()
|
|
|
|
|
|
|
|
popupMenu: ChatContextMenuView {
|
2022-03-07 14:56:05 +00:00
|
|
|
emojiPopup: chatContentRoot.emojiPopup
|
2021-12-21 09:26:13 +00:00
|
|
|
openHandler: function () {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on open chat context menu handler - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
currentFleet = chatContentModule.getCurrentFleet()
|
|
|
|
isCommunityChat = chatContentModule.chatDetails.belongsToCommunity
|
2022-01-05 15:50:03 +00:00
|
|
|
amIChatAdmin = chatContentModule.amIChatAdmin()
|
2021-12-21 09:26:13 +00:00
|
|
|
chatId = chatContentModule.chatDetails.id
|
|
|
|
chatName = chatContentModule.chatDetails.name
|
|
|
|
chatDescription = chatContentModule.chatDetails.description
|
2022-03-07 14:56:05 +00:00
|
|
|
chatEmoji = chatContentModule.chatDetails.emoji
|
2022-03-10 19:28:37 +00:00
|
|
|
chatColor = chatContentModule.chatDetails.color
|
2021-12-21 09:26:13 +00:00
|
|
|
chatType = chatContentModule.chatDetails.type
|
|
|
|
chatMuted = chatContentModule.chatDetails.muted
|
2022-02-24 21:38:32 +00:00
|
|
|
channelPosition = chatContentModule.chatDetails.position
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onMuteChat: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on mute chat from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
chatContentModule.muteChat()
|
|
|
|
}
|
|
|
|
|
|
|
|
onUnmuteChat: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on unmute chat from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
chatContentModule.unmuteChat()
|
|
|
|
}
|
|
|
|
|
|
|
|
onMarkAllMessagesRead: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on mark all messages read from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
chatContentModule.markAllMessagesRead()
|
|
|
|
}
|
|
|
|
|
|
|
|
onClearChatHistory: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on clear chat history from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
chatContentModule.clearChatHistory()
|
|
|
|
}
|
|
|
|
|
|
|
|
onRequestAllHistoricMessages: {
|
|
|
|
// Not Refactored Yet - Check in the `master` branch if this is applicable here.
|
|
|
|
}
|
|
|
|
|
|
|
|
onLeaveChat: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on leave chat from context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2021-12-21 09:26:13 +00:00
|
|
|
chatContentModule.leaveChat()
|
|
|
|
}
|
|
|
|
|
2022-01-25 12:09:27 +00:00
|
|
|
onDeleteCommunityChat: root.rootStore.removeCommunityChat(chatId)
|
2021-12-21 09:26:13 +00:00
|
|
|
|
|
|
|
onDownloadMessages: {
|
|
|
|
// Not Refactored Yet
|
|
|
|
}
|
|
|
|
|
|
|
|
onDisplayProfilePopup: {
|
2022-01-05 15:50:03 +00:00
|
|
|
Global.openProfilePopup(publicKey)
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onDisplayGroupInfoPopup: {
|
2021-12-08 12:31:28 +00:00
|
|
|
Global.openPopup(groupInfoPopupComponent, {
|
2022-02-14 12:18:25 +00:00
|
|
|
chatContentModule: chatContentModule,
|
|
|
|
chatDetails: chatContentModule.chatDetails
|
|
|
|
})
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
2022-02-24 21:38:32 +00:00
|
|
|
|
|
|
|
onEditCommunityChannel: {
|
|
|
|
root.rootStore.editCommunityChannel(
|
|
|
|
chatId,
|
|
|
|
newName,
|
|
|
|
newDescription,
|
2022-03-07 14:56:05 +00:00
|
|
|
newEmoji,
|
2022-03-10 19:28:37 +00:00
|
|
|
newColor,
|
2022-02-24 21:38:32 +00:00
|
|
|
newCategory,
|
|
|
|
channelPosition // TODO change this to the signal once it is modifiable
|
|
|
|
)
|
|
|
|
}
|
2022-02-15 21:00:05 +00:00
|
|
|
onAddRemoveGroupMember: {
|
|
|
|
chatContentRoot.rootStore.addRemoveGroupMember();
|
|
|
|
}
|
|
|
|
onFetchMoreMessages: {
|
|
|
|
chatContentRoot.rootStore.messageStore.requestMoreMessages();
|
|
|
|
}
|
|
|
|
onLeaveGroup: {
|
|
|
|
chatContentModule.leaveChat();
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: connectedStatusRect
|
|
|
|
Layout.fillWidth: true
|
|
|
|
height: 40
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
z: 60
|
|
|
|
visible: false
|
|
|
|
color: isConnected ? Style.current.green : Style.current.darkGrey
|
|
|
|
Text {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
color: Style.current.white
|
|
|
|
id: connectedStatusLbl
|
|
|
|
text: isConnected ?
|
|
|
|
//% "Connected"
|
|
|
|
qsTrId("connected") :
|
|
|
|
//% "Disconnected"
|
|
|
|
qsTrId("disconnected")
|
|
|
|
}
|
|
|
|
|
2022-02-25 18:15:35 +00:00
|
|
|
Connections {
|
|
|
|
target: mainModule
|
|
|
|
onOnlineStatusChanged: {
|
|
|
|
if (connected == isConnected) return;
|
|
|
|
isConnected = connected;
|
|
|
|
if(isConnected){
|
|
|
|
timer.setTimeout(function(){
|
|
|
|
connectedStatusRect.visible = false;
|
|
|
|
}, 5000);
|
|
|
|
} else {
|
|
|
|
connectedStatusRect.visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
isConnected = mainModule.isOnline
|
|
|
|
if(!isConnected){
|
|
|
|
connectedStatusRect.visible = true
|
|
|
|
}
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2022-02-04 10:21:05 +00:00
|
|
|
StatusBanner {
|
2021-12-09 12:53:40 +00:00
|
|
|
Layout.fillWidth: true
|
2022-02-04 10:21:05 +00:00
|
|
|
visible: chatContentRoot.isBlocked
|
|
|
|
type: StatusBanner.Type.Danger
|
|
|
|
statusText: qsTr("Blocked")
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
MessageStore {
|
2021-12-14 14:19:55 +00:00
|
|
|
id: messageStore
|
2022-01-11 23:16:17 +00:00
|
|
|
messageModule: chatContentModule? chatContentModule.messagesModule : null
|
2022-02-22 20:48:57 +00:00
|
|
|
chatSectionModule: chatContentRoot.rootStore.chatCommunitySectionModule
|
2021-12-14 14:19:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageContextMenuView {
|
|
|
|
id: contextmenu
|
2022-01-19 15:59:08 +00:00
|
|
|
store: chatContentRoot.rootStore
|
2021-12-22 14:55:13 +00:00
|
|
|
reactionModel: chatContentRoot.rootStore.emojiReactionsModel
|
2021-12-14 14:19:55 +00:00
|
|
|
onPinMessage: {
|
|
|
|
messageStore.pinMessage(messageId)
|
|
|
|
}
|
|
|
|
|
|
|
|
onUnpinMessage: {
|
|
|
|
messageStore.unpinMessage(messageId)
|
|
|
|
}
|
2021-12-17 12:53:10 +00:00
|
|
|
|
|
|
|
onPinnedMessagesLimitReached: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on open pinned messages limit reached from message context menu - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
2021-12-17 12:53:10 +00:00
|
|
|
Global.openPopup(pinnedMessagesPopupComponent, {
|
2022-01-19 15:59:08 +00:00
|
|
|
store: rootStore,
|
2022-01-12 12:55:26 +00:00
|
|
|
messageStore: messageStore,
|
|
|
|
pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
|
|
|
|
messageToPin: messageId
|
|
|
|
})
|
2021-12-17 12:53:10 +00:00
|
|
|
}
|
2021-12-20 14:21:35 +00:00
|
|
|
|
|
|
|
onToggleReaction: {
|
|
|
|
messageStore.toggleReaction(messageId, emojiId)
|
|
|
|
}
|
2022-01-05 15:50:03 +00:00
|
|
|
|
|
|
|
onOpenProfileClicked: {
|
|
|
|
Global.openProfilePopup(publicKey)
|
|
|
|
}
|
2022-01-13 15:14:34 +00:00
|
|
|
|
|
|
|
onDeleteMessage: {
|
|
|
|
messageStore.deleteMessage(messageId)
|
|
|
|
}
|
2022-01-17 18:46:46 +00:00
|
|
|
|
|
|
|
onEditClicked: messageStore.setEditModeOn(messageId)
|
2022-01-26 19:54:33 +00:00
|
|
|
|
|
|
|
onCreateOneToOneChat: {
|
|
|
|
Global.changeAppSectionBySectionType(Constants.appSection.chat)
|
2022-02-15 21:00:05 +00:00
|
|
|
root.rootStore.chatCommunitySectionModule.createOneToOneChat("", chatId, ensName)
|
2022-01-26 19:54:33 +00:00
|
|
|
}
|
2022-04-12 15:15:14 +00:00
|
|
|
onShowReplyArea: {
|
|
|
|
let obj = messageStore.getMessageByIdAsJson(messageId)
|
|
|
|
if (!obj) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatInput.showReplyArea(messageId, obj.senderDisplayName, obj.messageText, obj.senderIcon, obj.contentType, obj.messageImage, obj.sticker)
|
|
|
|
}
|
2021-12-14 14:19:55 +00:00
|
|
|
}
|
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
ChatMessagesView {
|
|
|
|
id: chatMessages
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2021-12-22 14:55:13 +00:00
|
|
|
store: chatContentRoot.rootStore
|
2022-01-04 12:06:05 +00:00
|
|
|
contactsStore: chatContentRoot.contactsStore
|
2021-12-09 12:53:40 +00:00
|
|
|
messageContextMenuInst: contextmenu
|
2021-12-14 14:19:55 +00:00
|
|
|
messageStore: messageStore
|
2022-04-13 09:59:16 +00:00
|
|
|
emojiPopup: chatContentRoot.emojiPopup
|
2022-02-08 12:08:02 +00:00
|
|
|
usersStore: chatContentRoot.usersStore
|
2022-01-05 15:50:03 +00:00
|
|
|
stickersLoaded: chatContentRoot.stickersLoaded
|
2022-02-24 12:15:02 +00:00
|
|
|
isChatBlocked: chatContentRoot.isBlocked
|
2022-03-14 19:32:52 +00:00
|
|
|
channelEmoji: chatContentModule.chatDetails.emoji || ""
|
2022-01-12 12:55:26 +00:00
|
|
|
onShowReplyArea: {
|
|
|
|
let obj = messageStore.getMessageByIdAsJson(messageId)
|
|
|
|
if (!obj) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
chatInput.showReplyArea(messageId, obj.senderDisplayName, obj.messageText, obj.senderIcon, obj.contentType, obj.messageImage, obj.sticker)
|
2022-02-14 23:27:23 +00:00
|
|
|
}
|
|
|
|
onOpenStickerPackPopup: {
|
|
|
|
root.openStickerPackPopup(stickerPackId);
|
2022-01-12 12:55:26 +00:00
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: inputArea
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
height: chatInput.height
|
|
|
|
Layout.preferredHeight: height
|
|
|
|
|
2022-01-19 16:29:11 +00:00
|
|
|
Loader {
|
|
|
|
id: loadingMessagesIndicator
|
2022-03-28 22:08:58 +00:00
|
|
|
active: root.rootStore.loadingHistoryMessagesInProgress
|
|
|
|
visible: root.rootStore.loadingHistoryMessagesInProgress
|
2022-01-19 16:29:11 +00:00
|
|
|
sourceComponent: LoadingAnimation { }
|
|
|
|
anchors {
|
|
|
|
right: parent.right
|
|
|
|
bottom: chatInput.top
|
|
|
|
rightMargin: Style.current.padding
|
|
|
|
bottomMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
StatusChatInput {
|
|
|
|
id: chatInput
|
2022-02-15 21:00:05 +00:00
|
|
|
store: chatContentRoot.rootStore
|
2022-02-08 12:08:02 +00:00
|
|
|
usersStore: chatContentRoot.usersStore
|
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
visible: {
|
2022-03-22 08:29:58 +00:00
|
|
|
return true
|
2022-02-15 21:00:05 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// if (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatType.privateGroupChat) {
|
|
|
|
// return chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.isMember
|
|
|
|
// }
|
|
|
|
// if (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType === Constants.chatType.oneToOne) {
|
|
|
|
// return isContact
|
|
|
|
// }
|
|
|
|
// const community = chatContentRoot.rootStore.chatsModelInst.communities.activeCommunity
|
|
|
|
// return !community.active ||
|
|
|
|
// community.access === Constants.communityChatPublicAccess ||
|
|
|
|
// community.admin ||
|
|
|
|
// chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.canPost
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
2022-02-01 13:10:24 +00:00
|
|
|
messageContextMenu: contextmenu
|
2022-03-07 14:56:05 +00:00
|
|
|
emojiPopup: chatContentRoot.emojiPopup
|
2022-02-04 10:21:05 +00:00
|
|
|
isContactBlocked: chatContentRoot.isBlocked
|
2022-02-28 20:14:04 +00:00
|
|
|
isActiveChannel: chatContentRoot.isActiveChannel
|
2022-02-04 10:21:05 +00:00
|
|
|
chatInputPlaceholder: chatContentRoot.isBlocked ?
|
2021-12-09 12:53:40 +00:00
|
|
|
//% "This user has been blocked."
|
|
|
|
qsTrId("this-user-has-been-blocked-") :
|
|
|
|
//% "Type a message."
|
|
|
|
qsTrId("type-a-message-")
|
|
|
|
anchors.bottom: parent.bottom
|
2021-12-22 14:55:13 +00:00
|
|
|
recentStickers: chatContentRoot.rootStore.stickersModuleInst.recent
|
|
|
|
stickerPackList: chatContentRoot.rootStore.stickersModuleInst.stickerPacks
|
2022-01-11 23:16:17 +00:00
|
|
|
chatType: chatContentModule? chatContentModule.chatDetails.type : Constants.chatType.unknown
|
2021-12-09 12:53:40 +00:00
|
|
|
onSendTransactionCommandButtonClicked: {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on sending transaction command - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-01-04 12:06:05 +00:00
|
|
|
if (Utils.getContactDetailsAsJson(chatContentModule.getMyChatId()).ensVerified) {
|
2021-12-23 20:46:58 +00:00
|
|
|
Global.openPopup(chatContentRoot.sendTransactionWithEnsModal)
|
|
|
|
} else {
|
|
|
|
Global.openPopup(chatContentRoot.sendTransactionNoEnsModal)
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
onReceiveTransactionCommandButtonClicked: {
|
2021-12-23 20:46:58 +00:00
|
|
|
Global.openPopup(chatContentRoot.receiveTransactionModal)
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
onStickerSelected: {
|
2021-12-22 14:55:13 +00:00
|
|
|
chatContentRoot.rootStore.sendSticker(chatContentModule.getMyChatId(),
|
2022-01-12 12:55:26 +00:00
|
|
|
hashId,
|
|
|
|
chatInput.isReply ? SelectedMessage.messageId : "",
|
|
|
|
packId)
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
2022-01-11 23:16:17 +00:00
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
|
|
|
|
onSendMessage: {
|
2022-03-22 08:29:58 +00:00
|
|
|
if (!chatContentModule) {
|
|
|
|
console.debug("error on sending message - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(chatContentRoot.rootStore.sendMessage(event,
|
|
|
|
chatInput.textInput.text,
|
|
|
|
chatInput.isReply? chatInput.replyMessageId : "",
|
|
|
|
chatInput.fileUrls
|
|
|
|
))
|
|
|
|
{
|
|
|
|
sendMessageSound.stop();
|
|
|
|
Qt.callLater(sendMessageSound.play);
|
|
|
|
|
|
|
|
chatInput.textInput.clear();
|
|
|
|
chatInput.textInput.textFormat = TextEdit.PlainText;
|
|
|
|
chatInput.textInput.textFormat = TextEdit.RichText;
|
2021-12-22 14:55:13 +00:00
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
2022-02-24 12:15:02 +00:00
|
|
|
|
|
|
|
onUnblockChat: {
|
|
|
|
chatContentModule.unblockChat()
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|