2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
2021-08-06 15:31:42 +00:00
|
|
|
import Qt.labs.platform 1.1
|
2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-04-28 15:30:41 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2021-07-06 09:42:51 +00:00
|
|
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2020-05-27 21:09:12 +00:00
|
|
|
import "../../../shared"
|
2020-09-29 09:06:57 +00:00
|
|
|
import "../../../shared/status"
|
2021-10-05 20:50:22 +00:00
|
|
|
import "../../../shared/popups"
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-06-25 16:27:46 +00:00
|
|
|
import "./components"
|
2020-05-27 21:59:34 +00:00
|
|
|
import "./ChatColumn"
|
2020-09-29 09:06:57 +00:00
|
|
|
import "./ChatColumn/ChatComponents"
|
2020-07-20 19:29:57 +00:00
|
|
|
import "./data"
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
Item {
|
2020-07-10 15:37:23 +00:00
|
|
|
id: chatColumnLayout
|
2021-07-22 14:53:19 +00:00
|
|
|
anchors.fill: parent
|
2020-11-19 18:30:09 +00:00
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
property alias pinnedMessagesPopupComponent: pinnedMessagesPopupComponent
|
2020-05-26 18:16:07 +00:00
|
|
|
property int chatGroupsListViewCount: 0
|
2020-07-09 17:47:36 +00:00
|
|
|
property bool isReply: false
|
2020-07-20 17:04:33 +00:00
|
|
|
property bool isImage: false
|
|
|
|
property bool isExtendedInput: isReply || isImage
|
2020-07-15 16:19:25 +00:00
|
|
|
property bool isConnected: false
|
2020-08-10 13:06:46 +00:00
|
|
|
property string contactToRemove: ""
|
2021-06-17 22:09:00 +00:00
|
|
|
property string activeChatId: chatsModel.channelView.activeChannel.id
|
2021-04-28 15:30:41 +00:00
|
|
|
property bool isBlocked: profileModel.contacts.isContactBlocked(activeChatId)
|
2021-05-26 17:36:24 +00:00
|
|
|
property bool isContact: profileModel.contacts.isAdded(activeChatId)
|
2021-05-26 18:56:04 +00:00
|
|
|
property bool contactRequestReceived: profileModel.contacts.contactRequestReceived(activeChatId)
|
2021-05-26 17:36:24 +00:00
|
|
|
property string currentNotificationChatId
|
|
|
|
property string currentNotificationCommunityId
|
2021-05-25 19:38:18 +00:00
|
|
|
property string hoveredMessage
|
|
|
|
property string activeMessage
|
2021-07-16 15:02:47 +00:00
|
|
|
property var currentTime: 0
|
|
|
|
property var idMap: ({})
|
|
|
|
property Timer timer: Timer { }
|
2021-07-22 14:53:19 +00:00
|
|
|
property var userList
|
2021-07-16 15:02:47 +00:00
|
|
|
property var onActivated: function () {
|
2021-09-21 12:26:32 +00:00
|
|
|
if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideChatInputExtendedArea () {
|
|
|
|
if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.hideExtendedArea()
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-05-25 19:38:18 +00:00
|
|
|
|
|
|
|
function setHovered(messageId, hovered) {
|
|
|
|
if (hovered) {
|
|
|
|
hoveredMessage = messageId
|
|
|
|
} else if (hoveredMessage === messageId) {
|
|
|
|
hoveredMessage = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setMessageActive(messageId, active) {
|
|
|
|
if (active) {
|
|
|
|
activeMessage = messageId
|
|
|
|
} else if (activeMessage === messageId) {
|
|
|
|
activeMessage = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-23 16:13:39 +00:00
|
|
|
function showReplyArea() {
|
2020-07-20 17:04:33 +00:00
|
|
|
isReply = true;
|
|
|
|
isImage = false;
|
2021-06-21 19:35:32 +00:00
|
|
|
let replyMessageIndex = chatsModel.messageView.messageList.getMessageIndex(SelectedMessage.messageId);
|
2020-09-29 09:06:57 +00:00
|
|
|
if (replyMessageIndex === -1) return;
|
2021-06-21 19:35:32 +00:00
|
|
|
let userName = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "userName")
|
|
|
|
let message = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "message")
|
|
|
|
let identicon = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "identicon")
|
2021-08-30 12:42:11 +00:00
|
|
|
let image = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "image")
|
|
|
|
let sticker = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "sticker")
|
|
|
|
let contentType = chatsModel.messageView.messageList.getMessageData(replyMessageIndex, "contentType")
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-09-21 12:26:32 +00:00
|
|
|
if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.showReplyArea(userName, message, identicon, contentType, image, sticker)
|
2020-07-20 17:04:33 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
function requestAddressForTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
|
2020-10-12 11:44:04 +00:00
|
|
|
amount = utilsModel.eth2Wei(amount.toString(), tokenDecimals)
|
2021-04-28 15:30:41 +00:00
|
|
|
chatsModel.transactions.requestAddress(activeChatId,
|
2020-12-06 15:24:28 +00:00
|
|
|
address,
|
|
|
|
amount,
|
|
|
|
tokenAddress)
|
2020-11-03 10:29:56 +00:00
|
|
|
txModalLoader.close()
|
2020-07-20 17:04:33 +00:00
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
function requestTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
|
2020-10-12 11:44:04 +00:00
|
|
|
amount = utilsModel.eth2Wei(amount.toString(), tokenDecimals)
|
2021-04-28 15:30:41 +00:00
|
|
|
chatsModel.transactions.request(activeChatId,
|
2020-09-29 09:06:57 +00:00
|
|
|
address,
|
|
|
|
amount,
|
|
|
|
tokenAddress)
|
2020-11-03 10:29:56 +00:00
|
|
|
txModalLoader.close()
|
2020-07-20 17:04:33 +00:00
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-05-26 17:36:24 +00:00
|
|
|
function clickOnNotification() {
|
2021-07-09 07:49:08 +00:00
|
|
|
// So far we're just showing this app as the top most window. Once we decide about the way
|
|
|
|
// how to notify the app what channle should be displayed within the app when user clicks
|
|
|
|
// notificaiton bubble this part should be updated accordingly.
|
|
|
|
//
|
|
|
|
// I removed part of this function which caused app crash.
|
2021-05-26 17:36:24 +00:00
|
|
|
applicationWindow.show()
|
|
|
|
applicationWindow.raise()
|
|
|
|
applicationWindow.requestActivate()
|
|
|
|
}
|
|
|
|
|
2021-09-24 14:04:49 +00:00
|
|
|
function positionAtMessage(messageId, isSearch = false) {
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].message.scrollToMessage(messageId, isSearch);
|
2021-05-26 17:36:24 +00:00
|
|
|
}
|
|
|
|
|
2021-04-07 18:26:03 +00:00
|
|
|
Timer {
|
2021-07-16 15:02:47 +00:00
|
|
|
interval: 60000; // 1 min
|
|
|
|
running: true
|
|
|
|
repeat: true
|
|
|
|
triggeredOnStart: true
|
|
|
|
onTriggered: {
|
|
|
|
chatColumnLayout.currentTime = Date.now()
|
|
|
|
}
|
2021-04-07 18:26:03 +00:00
|
|
|
}
|
2021-06-10 19:20:43 +00:00
|
|
|
|
2021-08-25 20:31:00 +00:00
|
|
|
MessageContextMenu {
|
|
|
|
id: contextmenu
|
|
|
|
reactionModel: EmojiReactions { }
|
|
|
|
}
|
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
StackLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
currentIndex: chatsModel.channelView.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
|
2020-05-26 15:55:32 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
StatusImageModal {
|
|
|
|
id: imagePopup
|
2021-08-16 09:11:43 +00:00
|
|
|
onClicked: {
|
|
|
|
if (button === Qt.LeftButton) {
|
|
|
|
imagePopup.close()
|
|
|
|
}
|
|
|
|
else if(button === Qt.RightButton) {
|
2021-08-25 20:31:00 +00:00
|
|
|
contextmenu.imageSource = imagePopup.imageSource
|
|
|
|
contextmenu.hideEmojiPicker = true
|
|
|
|
contextmenu.isRightClickOnImage = true;
|
|
|
|
contextmenu.show()
|
2021-08-16 09:11:43 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
StatusChatToolBar {
|
|
|
|
id: topBar
|
|
|
|
Layout.fillWidth: true
|
2021-07-06 09:42:51 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
property string chatId: chatsModel.channelView.activeChannel.id
|
|
|
|
property string profileImage: appMain.getProfileImage(chatId) || ""
|
2021-07-06 09:42:51 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
chatInfoButton.title: Utils.removeStatusEns(chatsModel.channelView.activeChannel.name)
|
|
|
|
chatInfoButton.subTitle: {
|
|
|
|
switch (chatsModel.channelView.activeChannel.chatType) {
|
2021-07-06 09:42:51 +00:00
|
|
|
case Constants.chatTypeOneToOne:
|
|
|
|
return (profileModel.contacts.isAdded(topBar.chatId) ?
|
2021-07-20 14:22:32 +00:00
|
|
|
//% "Contact"
|
|
|
|
qsTrId("chat-is-a-contact") :
|
|
|
|
//% "Not a contact"
|
|
|
|
qsTrId("chat-is-not-a-contact"))
|
2021-07-06 09:42:51 +00:00
|
|
|
case Constants.chatTypePublic:
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Public chat"
|
|
|
|
return qsTrId("public-chat")
|
2021-07-06 09:42:51 +00:00
|
|
|
case Constants.chatTypePrivateGroupChat:
|
|
|
|
let cnt = chatsModel.channelView.activeChannel.members.rowCount();
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "%1 members"
|
|
|
|
if(cnt > 1) return qsTrId("-1-members").arg(cnt);
|
|
|
|
//% "1 member"
|
|
|
|
return qsTrId("1-member");
|
2021-07-06 09:42:51 +00:00
|
|
|
case Constants.chatTypeCommunity:
|
2021-10-04 13:22:22 +00:00
|
|
|
return Utils.linkifyAndXSS(chatsModel.channelView.activeChannel.description).trim()
|
2021-07-06 09:42:51 +00:00
|
|
|
default:
|
|
|
|
return ""
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
chatInfoButton.image.source: profileImage || chatsModel.channelView.activeChannel.identicon
|
|
|
|
chatInfoButton.image.isIdenticon: !!!profileImage && chatsModel.channelView.activeChannel.identicon
|
|
|
|
chatInfoButton.icon.color: chatsModel.channelView.activeChannel.color
|
|
|
|
chatInfoButton.type: chatsModel.channelView.activeChannel.chatType
|
|
|
|
chatInfoButton.pinnedMessagesCount: chatsModel.messageView.pinnedMessagesList.count
|
|
|
|
chatInfoButton.muted: chatsModel.channelView.activeChannel.muted
|
|
|
|
|
|
|
|
chatInfoButton.onPinnedMessagesCountClicked: openPopup(pinnedMessagesPopupComponent)
|
|
|
|
chatInfoButton.onUnmute: chatsModel.channelView.unmuteChatItem(chatsModel.channelView.activeChannel.id)
|
|
|
|
|
|
|
|
chatInfoButton.sensor.enabled: chatsModel.channelView.activeChannel.chatType !== Constants.chatTypePublic &&
|
|
|
|
chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeCommunity
|
|
|
|
chatInfoButton.onClicked: {
|
|
|
|
switch (chatsModel.channelView.activeChannel.chatType) {
|
2021-07-06 09:42:51 +00:00
|
|
|
case Constants.chatTypePrivateGroupChat:
|
2021-07-28 10:41:37 +00:00
|
|
|
openPopup(groupInfoPopupComponent, {
|
|
|
|
channelType: GroupInfoPopup.ChannelType.ActiveChannel,
|
|
|
|
channel: chatsModel.channelView.activeChannel
|
|
|
|
})
|
2021-07-06 09:42:51 +00:00
|
|
|
break;
|
|
|
|
case Constants.chatTypeOneToOne:
|
|
|
|
openProfilePopup(chatsModel.userNameOrAlias(chatsModel.channelView.activeChannel.id),
|
2021-07-16 15:02:47 +00:00
|
|
|
chatsModel.channelView.activeChannel.id, profileImage || chatsModel.channelView.activeChannel.identicon,
|
|
|
|
"", chatsModel.channelView.activeChannel.nickname)
|
2021-07-06 09:42:51 +00:00
|
|
|
break;
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
|
2021-09-14 10:09:40 +00:00
|
|
|
membersButton.visible: (appSettings.showOnlineUsers || chatsModel.communities.activeCommunity.active)
|
|
|
|
&& chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne
|
|
|
|
membersButton.highlighted: appSettings.expandUsersList
|
2021-07-16 15:02:47 +00:00
|
|
|
notificationButton.visible: appSettings.isActivityCenterEnabled
|
2021-09-14 10:09:40 +00:00
|
|
|
notificationButton.tooltip.offset: appSettings.expandUsersList ? 0 : 14
|
2021-07-27 17:59:01 +00:00
|
|
|
notificationCount: chatsModel.activityNotificationList.unreadCount
|
2021-07-06 09:42:51 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
onSearchButtonClicked: searchPopup.open()
|
2021-07-12 17:42:40 +00:00
|
|
|
|
2021-09-14 10:09:40 +00:00
|
|
|
onMembersButtonClicked: appSettings.expandUsersList = !appSettings.expandUsersList
|
2021-07-16 15:02:47 +00:00
|
|
|
onNotificationButtonClicked: activityCenter.open()
|
2021-07-06 09:42:51 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
popupMenu: ChatContextMenu {
|
2021-09-14 09:58:20 +00:00
|
|
|
onOpened: {
|
2021-07-16 15:02:47 +00:00
|
|
|
chatItem = chatsModel.channelView.activeChannel
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
2020-07-15 16:19:25 +00:00
|
|
|
|
2021-07-16 15:02:47 +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")
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel
|
|
|
|
onOnlineStatusChanged: {
|
|
|
|
if (connected == isConnected) return;
|
|
|
|
isConnected = connected;
|
|
|
|
if(isConnected){
|
|
|
|
timer.setTimeout(function(){
|
|
|
|
connectedStatusRect.visible = false;
|
|
|
|
}, 5000);
|
|
|
|
} else {
|
|
|
|
connectedStatusRect.visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
|
|
isConnected = chatsModel.isOnline
|
|
|
|
if(!isConnected){
|
|
|
|
connectedStatusRect.visible = true
|
|
|
|
}
|
2020-07-15 16:19:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-20 04:41:56 +00:00
|
|
|
Item {
|
2021-08-09 11:11:04 +00:00
|
|
|
Layout.fillWidth: true
|
2021-08-20 04:41:56 +00:00
|
|
|
Layout.preferredHeight: 40
|
2021-08-09 11:11:04 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
visible: isBlocked
|
2021-08-20 04:41:56 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: blockedBanner
|
|
|
|
anchors.fill: parent
|
|
|
|
color: Style.current.red
|
|
|
|
opacity: 0.1
|
|
|
|
}
|
2021-08-09 11:11:04 +00:00
|
|
|
|
2021-08-17 16:31:52 +00:00
|
|
|
Text {
|
|
|
|
id: blockedText
|
|
|
|
anchors.centerIn: blockedBanner
|
|
|
|
color: Style.current.red
|
|
|
|
text: qsTr("Blocked")
|
|
|
|
}
|
2021-08-09 11:11:04 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackLayoutChatMessages
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
clip: true
|
2021-07-23 08:23:58 +00:00
|
|
|
currentIndex: chatsModel.messageView.getMessageListIndex(chatsModel.channelView.activeChannelIndex)
|
2021-07-16 15:02:47 +00:00
|
|
|
Repeater {
|
|
|
|
model: chatsModel.messageView
|
2021-09-21 12:26:32 +00:00
|
|
|
ColumnLayout {
|
|
|
|
property alias chatInput: chatInput
|
2021-09-22 08:25:55 +00:00
|
|
|
property alias message: messageLoader.item
|
2021-09-21 12:26:32 +00:00
|
|
|
Loader {
|
2021-09-22 08:25:55 +00:00
|
|
|
id: messageLoader
|
2021-09-21 12:26:32 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
|
|
|
|
active: stackLayoutChatMessages.currentIndex === index
|
|
|
|
sourceComponent: ChatMessages {
|
|
|
|
id: chatMessages
|
|
|
|
messageList: messages
|
|
|
|
messageContextMenuInst: contextmenu
|
|
|
|
Component.onCompleted: {
|
|
|
|
chatColumnLayout.userList = chatMessages.messageList.userList;
|
|
|
|
}
|
2021-07-22 14:53:19 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-09-21 12:26:32 +00:00
|
|
|
Item {
|
|
|
|
id: inputArea
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
height: chatInput.height
|
|
|
|
Layout.preferredHeight: height
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel.messageView
|
|
|
|
onLoadingMessagesChanged:
|
|
|
|
if(value){
|
|
|
|
loadingMessagesIndicator.active = true
|
|
|
|
} else {
|
|
|
|
timer.setTimeout(function(){
|
|
|
|
loadingMessagesIndicator.active = false;
|
|
|
|
}, 5000);
|
|
|
|
}
|
|
|
|
}
|
2021-05-26 17:36:24 +00:00
|
|
|
|
2021-09-21 12:26:32 +00:00
|
|
|
Loader {
|
|
|
|
id: loadingMessagesIndicator
|
|
|
|
active: chatsModel.messageView.loadingMessages
|
|
|
|
sourceComponent: loadingIndicator
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: chatInput.top
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
}
|
2021-06-21 19:35:32 +00:00
|
|
|
|
2021-09-21 12:26:32 +00:00
|
|
|
Component {
|
|
|
|
id: loadingIndicator
|
|
|
|
LoadingAnimation { }
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
2021-09-21 12:26:32 +00:00
|
|
|
StatusChatInput {
|
|
|
|
id: chatInput
|
|
|
|
visible: {
|
|
|
|
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
|
|
|
|
return chatsModel.channelView.activeChannel.isMember
|
|
|
|
}
|
|
|
|
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) {
|
|
|
|
return isContact
|
|
|
|
}
|
|
|
|
const community = chatsModel.communities.activeCommunity
|
|
|
|
return !community.active ||
|
|
|
|
community.access === Constants.communityChatPublicAccess ||
|
|
|
|
community.admin ||
|
|
|
|
chatsModel.channelView.activeChannel.canPost
|
|
|
|
}
|
|
|
|
isContactBlocked: isBlocked
|
|
|
|
chatInputPlaceholder: isBlocked ?
|
|
|
|
//% "This user has been blocked."
|
|
|
|
qsTrId("this-user-has-been-blocked-") :
|
|
|
|
//% "Type a message."
|
|
|
|
qsTrId("type-a-message-")
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
recentStickers: chatsModel.stickers.recent
|
|
|
|
stickerPackList: chatsModel.stickers.stickerPacks
|
|
|
|
chatType: chatsModel.channelView.activeChannel.chatType
|
|
|
|
onSendTransactionCommandButtonClicked: {
|
|
|
|
if (chatsModel.channelView.activeChannel.ensVerified) {
|
|
|
|
txModalLoader.sourceComponent = cmpSendTransactionWithEns
|
|
|
|
} else {
|
|
|
|
txModalLoader.sourceComponent = cmpSendTransactionNoEns
|
|
|
|
}
|
|
|
|
txModalLoader.item.open()
|
|
|
|
}
|
|
|
|
onReceiveTransactionCommandButtonClicked: {
|
|
|
|
txModalLoader.sourceComponent = cmpReceiveTransaction
|
|
|
|
txModalLoader.item.open()
|
|
|
|
}
|
|
|
|
onStickerSelected: {
|
|
|
|
chatsModel.stickers.send(hashId, chatInput.isReply ? SelectedMessage.messageId : "", packId)
|
|
|
|
}
|
|
|
|
onSendMessage: {
|
|
|
|
if (chatInput.fileUrls.length > 0){
|
|
|
|
chatsModel.sendImages(JSON.stringify(fileUrls));
|
|
|
|
}
|
|
|
|
let msg = chatsModel.plainText(Emoji.deparse(chatInput.textInput.text))
|
|
|
|
if (msg.length > 0){
|
|
|
|
msg = chatInput.interpretMessage(msg)
|
|
|
|
chatsModel.messageView.sendMessage(msg, chatInput.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, false);
|
|
|
|
if(event) event.accepted = true
|
|
|
|
sendMessageSound.stop();
|
|
|
|
Qt.callLater(sendMessageSound.play);
|
|
|
|
|
|
|
|
chatInput.textInput.clear();
|
|
|
|
chatInput.textInput.textFormat = TextEdit.PlainText;
|
|
|
|
chatInput.textInput.textFormat = TextEdit.RichText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-09-21 12:26:32 +00:00
|
|
|
Connections {
|
|
|
|
target: chatsModel.channelView
|
|
|
|
onActiveChannelChanged: {
|
|
|
|
isBlocked = profileModel.contacts.isContactBlocked(activeChatId);
|
|
|
|
chatInput.suggestions.hide();
|
|
|
|
if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-21 12:26:32 +00:00
|
|
|
}
|
2021-08-09 11:11:04 +00:00
|
|
|
|
2021-09-21 12:26:32 +00:00
|
|
|
ChatRequestMessage {
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-05-18 17:17:04 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
EmptyChat { }
|
2021-05-18 17:17:04 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
Loader {
|
|
|
|
id: txModalLoader
|
|
|
|
function close() {
|
|
|
|
if (!this.item) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.item.close()
|
|
|
|
this.closed()
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
function closed() {
|
|
|
|
this.sourceComponent = undefined
|
|
|
|
}
|
|
|
|
}
|
2021-05-18 17:17:04 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
Component {
|
|
|
|
id: cmpSendTransactionNoEns
|
|
|
|
ChatCommandModal {
|
|
|
|
id: sendTransactionNoEns
|
|
|
|
onClosed: {
|
|
|
|
txModalLoader.closed()
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
sendChatCommand: chatColumnLayout.requestAddressForTransaction
|
|
|
|
isRequested: false
|
|
|
|
//% "Send"
|
|
|
|
commandTitle: qsTrId("command-button-send")
|
|
|
|
title: commandTitle
|
|
|
|
//% "Request Address"
|
|
|
|
finalButtonLabel: qsTrId("request-address")
|
|
|
|
selectRecipient.selectedRecipient: {
|
|
|
|
return {
|
|
|
|
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
|
|
|
|
alias: chatsModel.channelView.activeChannel.alias,
|
|
|
|
identicon: chatsModel.channelView.activeChannel.identicon,
|
|
|
|
name: chatsModel.channelView.activeChannel.name,
|
|
|
|
type: RecipientSelector.Type.Contact
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
|
|
|
selectRecipient.readOnly: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: cmpReceiveTransaction
|
|
|
|
ChatCommandModal {
|
|
|
|
id: receiveTransaction
|
|
|
|
onClosed: {
|
|
|
|
txModalLoader.closed()
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
sendChatCommand: chatColumnLayout.requestTransaction
|
|
|
|
isRequested: true
|
|
|
|
//% "Request"
|
|
|
|
commandTitle: qsTrId("wallet-request")
|
|
|
|
title: commandTitle
|
|
|
|
//% "Request"
|
|
|
|
finalButtonLabel: qsTrId("wallet-request")
|
|
|
|
selectRecipient.selectedRecipient: {
|
|
|
|
return {
|
|
|
|
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
|
|
|
|
alias: chatsModel.channelView.activeChannel.alias,
|
|
|
|
identicon: chatsModel.channelView.activeChannel.identicon,
|
|
|
|
name: chatsModel.channelView.activeChannel.name,
|
|
|
|
type: RecipientSelector.Type.Contact
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
|
|
|
selectRecipient.readOnly: true
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
Component {
|
|
|
|
id: cmpSendTransactionWithEns
|
|
|
|
SendModal {
|
|
|
|
id: sendTransactionWithEns
|
|
|
|
onOpened: {
|
2021-07-05 12:34:56 +00:00
|
|
|
walletModel.gasView.getGasPrice()
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
txModalLoader.closed()
|
|
|
|
}
|
|
|
|
selectRecipient.readOnly: true
|
|
|
|
selectRecipient.selectedRecipient: {
|
|
|
|
return {
|
|
|
|
address: "",
|
|
|
|
alias: chatsModel.channelView.activeChannel.alias,
|
|
|
|
identicon: chatsModel.channelView.activeChannel.identicon,
|
|
|
|
name: chatsModel.channelView.activeChannel.name,
|
|
|
|
type: RecipientSelector.Type.Contact,
|
|
|
|
ensVerified: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
2020-11-03 10:29:56 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
ActivityCenter {
|
|
|
|
id: activityCenter
|
|
|
|
height: chatColumnLayout.height - (topBar.height * 2) // TODO get screen size
|
|
|
|
y: topBar.height
|
2020-11-03 10:29:56 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: profileModel.contacts
|
|
|
|
onContactListChanged: {
|
|
|
|
isBlocked = profileModel.contacts.isContactBlocked(activeChatId);
|
2020-11-03 10:29:56 +00:00
|
|
|
}
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel.channelView
|
|
|
|
onActiveChannelChanged: {
|
|
|
|
chatsModel.messageView.hideLoadingIndicator()
|
|
|
|
SelectedMessage.reset();
|
|
|
|
chatColumn.isReply = false;
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: systemTray
|
|
|
|
onMessageClicked: function () {
|
|
|
|
clickOnNotification()
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-06 09:42:51 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
Component {
|
|
|
|
id: pinnedMessagesPopupComponent
|
|
|
|
PinnedMessagesPopup {
|
|
|
|
id: pinnedMessagesPopup
|
|
|
|
onClosed: destroy()
|
|
|
|
}
|
|
|
|
}
|
2021-07-14 12:35:37 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
Connections {
|
|
|
|
target: chatsModel.messageView
|
2021-07-14 12:35:37 +00:00
|
|
|
|
2021-07-26 08:08:03 +00:00
|
|
|
onSearchedMessageLoaded: {
|
2021-09-24 14:04:49 +00:00
|
|
|
positionAtMessage(messageId, true);
|
2021-07-26 08:08:03 +00:00
|
|
|
}
|
|
|
|
|
2021-08-18 14:43:59 +00:00
|
|
|
onMessageNotificationPushed: function(messageId, communityId, chatId, msg, contentType, chatType, timestamp, identicon, username, hasMention, isAddedContact, channelName) {
|
2021-07-16 15:02:47 +00:00
|
|
|
if (appSettings.notificationSetting == Constants.notifyAllMessages ||
|
|
|
|
(appSettings.notificationSetting == Constants.notifyJustMentions && hasMention)) {
|
|
|
|
if (chatId === chatsModel.channelView.activeChannel.id && applicationWindow.active === true) {
|
|
|
|
// Do not show the notif if we are in the channel already and the window is active and focused
|
|
|
|
return
|
|
|
|
}
|
2021-07-14 12:35:37 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
chatColumnLayout.currentNotificationChatId = chatId
|
|
|
|
chatColumnLayout.currentNotificationCommunityId = null
|
2021-07-14 12:35:37 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
let name;
|
|
|
|
if (appSettings.notificationMessagePreviewSetting === Constants.notificationPreviewAnonymous) {
|
|
|
|
name = "Status"
|
|
|
|
} else if (chatType === Constants.chatTypePublic) {
|
|
|
|
name = chatId
|
|
|
|
} else {
|
|
|
|
name = chatType === Constants.chatTypePrivateGroupChat ? Utils.filterXSS(channelName) : Utils.removeStatusEns(username)
|
|
|
|
}
|
2021-07-14 12:35:37 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
let message;
|
|
|
|
if (appSettings.notificationMessagePreviewSetting > Constants.notificationPreviewNameOnly) {
|
|
|
|
switch(contentType){
|
|
|
|
//% "Image"
|
|
|
|
case Constants.imageType: message = qsTrId("image"); break
|
|
|
|
//% "Sticker"
|
|
|
|
case Constants.stickerType: message = qsTrId("sticker"); break
|
|
|
|
default: message = msg // don't parse emojis here as it emits HTML
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//% "You have a new message"
|
|
|
|
message = qsTrId("you-have-a-new-message")
|
2021-07-14 12:35:37 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
currentlyHasANotification = true
|
2021-08-18 14:43:59 +00:00
|
|
|
|
|
|
|
// Note:
|
|
|
|
// Show notification should be moved to the nim side.
|
|
|
|
// Left here only cause we don't have a way to deal with translations on the nim side.
|
|
|
|
chatsModel.showOSNotification(name,
|
|
|
|
message,
|
|
|
|
Constants.osNotificationType.newMessage,
|
|
|
|
communityId,
|
|
|
|
chatId,
|
|
|
|
messageId,
|
|
|
|
appSettings.useOSNotifications)
|
2021-07-14 12:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
2021-09-21 12:26:32 +00:00
|
|
|
if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-07-27 14:04:05 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel.stickers
|
|
|
|
onTransactionWasSent: {
|
2021-07-05 12:34:56 +00:00
|
|
|
//% "Transaction pending..."
|
|
|
|
toastMessage.title = qsTr("Transaction pending...")
|
2021-09-28 15:04:06 +00:00
|
|
|
toastMessage.source = Style.svg("loading")
|
2021-07-27 14:04:05 +00:00
|
|
|
toastMessage.iconColor = Style.current.primary
|
|
|
|
toastMessage.iconRotates = true
|
|
|
|
toastMessage.link = `${walletModel.utilsView.etherscanLink}/${txResult}`
|
|
|
|
toastMessage.open()
|
|
|
|
}
|
|
|
|
onTransactionCompleted: {
|
2021-08-19 13:04:52 +00:00
|
|
|
toastMessage.title = !success ?
|
2021-07-27 14:04:05 +00:00
|
|
|
//% "Could not buy Stickerpack"
|
|
|
|
qsTrId("could-not-buy-stickerpack")
|
|
|
|
:
|
|
|
|
//% "Stickerpack bought successfully"
|
|
|
|
qsTrId("stickerpack-bought-successfully");
|
|
|
|
if (success) {
|
2021-09-28 15:04:06 +00:00
|
|
|
toastMessage.source = Style.svg("check-circle")
|
2021-07-27 14:04:05 +00:00
|
|
|
toastMessage.iconColor = Style.current.success
|
|
|
|
} else {
|
2021-09-28 15:04:06 +00:00
|
|
|
toastMessage.source = Style.svg("block-icon")
|
2021-07-27 14:04:05 +00:00
|
|
|
toastMessage.iconColor = Style.current.danger
|
|
|
|
}
|
|
|
|
|
|
|
|
toastMessage.link = `${walletModel.utilsView.etherscanLink}/${txHash}`
|
|
|
|
toastMessage.open()
|
|
|
|
}
|
|
|
|
}
|
2021-07-14 12:35:37 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-05-27 17:26:21 +00:00
|
|
|
D{i:0;formeditorColor:"#ffffff";height:770;width:800}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
2021-05-26 18:56:04 +00:00
|
|
|
##^##*/
|