2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2021-04-28 15:30:41 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2020-05-27 21:09:12 +00:00
|
|
|
import "../../../shared"
|
2020-09-29 09:06:57 +00:00
|
|
|
import "../../../shared/status"
|
2020-05-25 20:34:26 +00:00
|
|
|
import "../../../imports"
|
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"
|
2020-10-28 07:44:09 +00:00
|
|
|
import "../Wallet"
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
StackLayout {
|
2020-07-10 15:37:23 +00:00
|
|
|
id: chatColumnLayout
|
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-20 17:04:33 +00:00
|
|
|
|
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-30 18:46:26 +00:00
|
|
|
|
|
|
|
property bool showUsers: false
|
2020-08-10 13:06:46 +00:00
|
|
|
|
2021-04-28 15:30:41 +00:00
|
|
|
property var doNotShowAddToContactBannerToThose: ([])
|
|
|
|
|
2020-09-23 07:28:20 +00:00
|
|
|
property var onActivated: function () {
|
2021-05-18 17:17:04 +00:00
|
|
|
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
2020-09-23 07:28:20 +00:00
|
|
|
}
|
|
|
|
|
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-05 18:19:55 +00:00
|
|
|
|
2021-05-26 17:36:24 +00:00
|
|
|
property string currentNotificationChatId
|
|
|
|
property string currentNotificationCommunityId
|
2021-05-18 17:17:04 +00:00
|
|
|
property alias input: chatInput
|
2020-12-02 09:10:22 +00:00
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
property string hoveredMessage
|
|
|
|
property string activeMessage
|
|
|
|
|
|
|
|
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 07:28:20 +00:00
|
|
|
Component.onCompleted: {
|
2021-05-18 17:17:04 +00:00
|
|
|
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
2020-09-23 07:28:20 +00:00
|
|
|
}
|
|
|
|
|
2021-06-30 18:46:26 +00:00
|
|
|
property var currentTime: 0
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
interval: 60000; // 1 min
|
|
|
|
running: true;
|
|
|
|
repeat: true
|
|
|
|
onTriggered: {
|
|
|
|
chatColumnLayout.currentTime = Date.now()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
2020-05-28 12:56:43 +00:00
|
|
|
Layout.minimumWidth: 300
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2021-06-17 22:09:00 +00:00
|
|
|
currentIndex: chatsModel.channelView.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
|
2020-05-26 15:55:32 +00:00
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
Component {
|
|
|
|
id: pinnedMessagesPopupComponent
|
|
|
|
PinnedMessagesPopup {
|
|
|
|
id: pinnedMessagesPopup
|
|
|
|
onClosed: destroy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageContextMenu {
|
|
|
|
id: messageContextMenu
|
|
|
|
}
|
2021-02-03 21:38:05 +00:00
|
|
|
|
2021-06-02 20:02:28 +00:00
|
|
|
StatusImageModal {
|
|
|
|
id: imagePopup
|
|
|
|
}
|
|
|
|
|
2021-02-15 16:29:16 +00:00
|
|
|
property var idMap: ({})
|
2021-03-23 15:57:19 +00:00
|
|
|
property var suggestionsObj: ([])
|
2021-02-03 21:38:05 +00:00
|
|
|
|
|
|
|
function addSuggestionFromMessageList(i){
|
2021-06-21 19:35:32 +00:00
|
|
|
const contactAddr = chatsModel.messageView.messageList.getMessageData(i, "publicKey");
|
2021-02-03 21:38:05 +00:00
|
|
|
if(idMap[contactAddr]) return;
|
2021-03-23 15:57:19 +00:00
|
|
|
suggestionsObj.push({
|
2021-06-21 19:35:32 +00:00
|
|
|
alias: chatsModel.messageView.messageList.getMessageData(i, "alias"),
|
|
|
|
ensName: chatsModel.messageView.messageList.getMessageData(i, "ensName"),
|
2021-03-23 15:57:19 +00:00
|
|
|
address: contactAddr,
|
2021-06-21 19:35:32 +00:00
|
|
|
identicon: chatsModel.messageView.messageList.getMessageData(i, "identicon"),
|
|
|
|
localNickname: chatsModel.messageView.messageList.getMessageData(i, "localName")
|
2021-03-23 15:57:19 +00:00
|
|
|
})
|
2021-05-18 17:17:04 +00:00
|
|
|
chatInput.suggestionsList.append(suggestionsObj[suggestionsObj.length - 1]);
|
2021-02-03 21:38:05 +00:00
|
|
|
idMap[contactAddr] = true;
|
|
|
|
}
|
|
|
|
|
2021-03-23 15:57:19 +00:00
|
|
|
function populateSuggestions() {
|
2021-05-18 17:17:04 +00:00
|
|
|
chatInput.suggestionsList.clear()
|
2021-02-03 20:13:05 +00:00
|
|
|
const len = chatsModel.suggestionList.rowCount()
|
|
|
|
|
2021-02-03 21:38:05 +00:00
|
|
|
idMap = {}
|
2021-02-03 20:13:05 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
const contactAddr = chatsModel.suggestionList.rowData(i, "address");
|
|
|
|
if(idMap[contactAddr]) continue;
|
2021-03-23 15:57:19 +00:00
|
|
|
suggestionsObj.push({
|
|
|
|
alias: chatsModel.suggestionList.rowData(i, "alias"),
|
|
|
|
ensName: chatsModel.suggestionList.rowData(i, "ensName"),
|
|
|
|
address: contactAddr,
|
2021-05-07 06:26:58 +00:00
|
|
|
identicon: getProfileImage(contactAddr, false, false) || chatsModel.suggestionList.rowData(i, "identicon"),
|
2021-03-23 15:57:19 +00:00
|
|
|
localNickname: chatsModel.suggestionList.rowData(i, "localNickname")
|
|
|
|
})
|
|
|
|
|
2021-05-18 17:17:04 +00:00
|
|
|
chatInput.suggestionsList.append(suggestionsObj[suggestionsObj.length - 1]);
|
2021-02-03 20:13:05 +00:00
|
|
|
idMap[contactAddr] = true;
|
|
|
|
}
|
2021-06-21 19:35:32 +00:00
|
|
|
const len2 = chatsModel.messageView.messageList.rowCount();
|
2021-02-15 16:29:16 +00:00
|
|
|
for (let f = 0; f < len2; f++) {
|
|
|
|
addSuggestionFromMessageList(f);
|
2021-02-03 20:13:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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")
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-05-18 17:17:04 +00:00
|
|
|
chatInput.showReplyArea(userName, message, identicon)
|
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
|
|
|
|
2020-12-03 21:58:36 +00:00
|
|
|
Connections {
|
2020-12-06 22:15:51 +00:00
|
|
|
target: profileModel.contacts
|
2020-12-03 21:58:36 +00:00
|
|
|
onContactListChanged: {
|
2021-04-28 15:30:41 +00:00
|
|
|
isBlocked = profileModel.contacts.isContactBlocked(activeChatId);
|
2020-12-03 21:58:36 +00:00
|
|
|
}
|
2021-05-05 13:29:33 +00:00
|
|
|
onContactBlocked: {
|
2021-06-21 19:35:32 +00:00
|
|
|
chatsModel.messageView.removeMessagesByUserId(publicKey)
|
2021-05-05 13:29:33 +00:00
|
|
|
}
|
2020-12-03 21:58:36 +00:00
|
|
|
}
|
2021-04-07 18:26:03 +00:00
|
|
|
|
2021-05-26 17:36:24 +00:00
|
|
|
function clickOnNotification() {
|
|
|
|
applicationWindow.show()
|
|
|
|
applicationWindow.raise()
|
|
|
|
applicationWindow.requestActivate()
|
|
|
|
appMain.changeAppSection(Constants.chat)
|
|
|
|
if (currentNotificationChatId) {
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.setActiveChannel(currentNotificationChatId)
|
2021-05-26 17:36:24 +00:00
|
|
|
} else if (currentNotificationCommunityId) {
|
|
|
|
chatsModel.communities.setActiveCommunity(currentNotificationCommunityId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: systemTray
|
|
|
|
onMessageClicked: function () {
|
|
|
|
clickOnNotification()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-07 18:26:03 +00:00
|
|
|
Timer {
|
|
|
|
id: timer
|
|
|
|
}
|
2021-06-10 19:20:43 +00:00
|
|
|
|
|
|
|
function positionAtMessage(messageId) {
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].item.scrollToMessage(messageId)
|
|
|
|
}
|
2020-07-20 17:04:33 +00:00
|
|
|
|
2020-05-26 18:16:07 +00:00
|
|
|
ColumnLayout {
|
2020-07-09 17:47:36 +00:00
|
|
|
spacing: 0
|
2020-05-26 15:55:32 +00:00
|
|
|
|
2021-04-07 18:26:03 +00:00
|
|
|
TopBar {
|
|
|
|
id: topBar
|
|
|
|
z: 60
|
2020-05-26 18:16:07 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
2020-05-26 15:55:32 +00:00
|
|
|
Layout.fillWidth: true
|
2020-07-15 16:19:25 +00:00
|
|
|
}
|
|
|
|
|
2021-04-07 18:26:03 +00:00
|
|
|
Rectangle {
|
|
|
|
Component.onCompleted: {
|
|
|
|
isConnected = chatsModel.isOnline
|
|
|
|
if(!isConnected){
|
|
|
|
connectedStatusRect.visible = true
|
2020-07-15 16:19:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-07 18:26:03 +00:00
|
|
|
id: connectedStatusRect
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
z: 60
|
|
|
|
height: 40
|
|
|
|
color: isConnected ? Style.current.green : Style.current.darkGrey
|
|
|
|
visible: false
|
|
|
|
Text {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
color: Style.current.white
|
|
|
|
id: connectedStatusLbl
|
|
|
|
text: isConnected ?
|
|
|
|
//% "Connected"
|
|
|
|
qsTrId("connected") :
|
|
|
|
//% "Disconnected"
|
|
|
|
qsTrId("disconnected")
|
2020-07-15 16:19:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: chatsModel
|
|
|
|
onOnlineStatusChanged: {
|
2020-07-24 14:33:17 +00:00
|
|
|
if (connected == isConnected) return;
|
|
|
|
isConnected = connected;
|
|
|
|
if(isConnected){
|
2021-04-07 18:26:03 +00:00
|
|
|
timer.setTimeout(function(){
|
2020-07-15 16:19:25 +00:00
|
|
|
connectedStatusRect.visible = false;
|
|
|
|
}, 5000);
|
|
|
|
} else {
|
|
|
|
connectedStatusRect.visible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 17:36:24 +00:00
|
|
|
AddToContactBanner {
|
2021-04-28 15:30:41 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2021-04-07 18:26:03 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackLayoutChatMessages
|
2020-05-25 20:34:26 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2021-04-07 18:26:03 +00:00
|
|
|
clip: true
|
|
|
|
Repeater {
|
2021-06-21 19:35:32 +00:00
|
|
|
model: chatsModel.messageView
|
2021-04-07 18:26:03 +00:00
|
|
|
Loader {
|
|
|
|
active: false
|
|
|
|
sourceComponent: ChatMessages {
|
|
|
|
id: chatMessages
|
|
|
|
messageList: model.messages
|
2021-06-30 18:46:26 +00:00
|
|
|
currentTime: chatColumnLayout.currentTime
|
2021-04-07 18:26:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-22 18:09:26 +00:00
|
|
|
|
|
|
|
Connections {
|
2021-06-17 22:09:00 +00:00
|
|
|
target: chatsModel.channelView
|
2021-02-22 18:09:26 +00:00
|
|
|
onActiveChannelChanged: {
|
2021-06-21 19:35:32 +00:00
|
|
|
stackLayoutChatMessages.currentIndex = chatsModel.messageView.getMessageListIndex(chatsModel.channelView.activeChannelIndex)
|
2021-02-28 15:33:25 +00:00
|
|
|
if(stackLayoutChatMessages.currentIndex > -1 && !stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].active){
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].active = true;
|
|
|
|
}
|
2021-02-22 18:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-07 18:26:03 +00:00
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2020-07-20 19:29:57 +00:00
|
|
|
EmojiReactions {
|
|
|
|
id: reactionModel
|
|
|
|
}
|
|
|
|
|
2020-07-14 11:40:58 +00:00
|
|
|
Connections {
|
2021-06-17 22:09:00 +00:00
|
|
|
target: chatsModel.channelView
|
2020-07-14 11:40:58 +00:00
|
|
|
onActiveChannelChanged: {
|
2021-05-18 17:17:04 +00:00
|
|
|
chatInput.suggestions.hide();
|
|
|
|
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
2021-02-03 20:13:05 +00:00
|
|
|
populateSuggestions();
|
|
|
|
}
|
2021-06-17 22:09:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
2021-06-21 19:35:32 +00:00
|
|
|
target: chatsModel.messageView
|
2021-02-03 20:13:05 +00:00
|
|
|
onMessagePushed: {
|
2021-02-03 21:38:05 +00:00
|
|
|
addSuggestionFromMessageList(messageIndex);
|
2020-07-14 11:40:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-07 06:26:58 +00:00
|
|
|
Connections {
|
|
|
|
target: profileModel
|
|
|
|
onContactsChanged: {
|
|
|
|
populateSuggestions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-26 17:36:24 +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
|
|
|
Item {
|
2020-07-09 17:47:36 +00:00
|
|
|
id: inputArea
|
2020-06-24 03:23:49 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
2020-05-25 20:34:26 +00:00
|
|
|
Layout.fillWidth: true
|
2020-06-24 03:23:49 +00:00
|
|
|
Layout.preferredWidth: parent.width
|
2021-05-18 17:17:04 +00:00
|
|
|
height: chatInput.height
|
|
|
|
Layout.preferredHeight: height
|
2021-06-21 19:35:32 +00:00
|
|
|
|
2021-05-18 17:17:04 +00:00
|
|
|
Connections {
|
2021-06-21 19:35:32 +00:00
|
|
|
target: chatsModel.messageView
|
2021-05-18 17:17:04 +00:00
|
|
|
onLoadingMessagesChanged:
|
|
|
|
if(value){
|
|
|
|
loadingMessagesIndicator.active = true
|
|
|
|
} else {
|
|
|
|
timer.setTimeout(function(){
|
|
|
|
loadingMessagesIndicator.active = false;
|
|
|
|
}, 5000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loadingMessagesIndicator
|
2021-06-21 19:35:32 +00:00
|
|
|
active: chatsModel.messageView.loadingMessages
|
2021-05-18 17:17:04 +00:00
|
|
|
sourceComponent: loadingIndicator
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: chatInput.top
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: loadingIndicator
|
|
|
|
LoadingAnimation {}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusChatInput {
|
|
|
|
id: chatInput
|
|
|
|
visible: {
|
2021-06-17 22:09:00 +00:00
|
|
|
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
|
|
|
|
return chatsModel.channelView.activeChannel.isMember
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
2021-06-17 22:09:00 +00:00
|
|
|
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) {
|
2021-05-26 18:56:04 +00:00
|
|
|
return isContact && contactRequestReceived
|
|
|
|
}
|
|
|
|
const community = chatsModel.communities.activeCommunity
|
2021-05-18 17:17:04 +00:00
|
|
|
return !community.active ||
|
|
|
|
community.access === Constants.communityChatPublicAccess ||
|
|
|
|
community.admin ||
|
2021-06-17 22:09:00 +00:00
|
|
|
chatsModel.channelView.activeChannel.canPost
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
|
|
|
enabled: !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
|
2021-06-17 22:09:00 +00:00
|
|
|
chatType: chatsModel.channelView.activeChannel.chatType
|
2021-05-18 17:17:04 +00:00
|
|
|
onSendTransactionCommandButtonClicked: {
|
2021-06-17 22:09:00 +00:00
|
|
|
if (chatsModel.channelView.activeChannel.ensVerified) {
|
2021-05-18 17:17:04 +00:00
|
|
|
txModalLoader.sourceComponent = cmpSendTransactionWithEns
|
|
|
|
} else {
|
|
|
|
txModalLoader.sourceComponent = cmpSendTransactionNoEns
|
|
|
|
}
|
|
|
|
txModalLoader.item.open()
|
|
|
|
}
|
|
|
|
onReceiveTransactionCommandButtonClicked: {
|
|
|
|
txModalLoader.sourceComponent = cmpReceiveTransaction
|
|
|
|
txModalLoader.item.open()
|
|
|
|
}
|
|
|
|
onStickerSelected: {
|
|
|
|
chatsModel.stickers.send(hashId, 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)
|
2021-06-21 19:35:32 +00:00
|
|
|
chatsModel.messageView.sendMessage(msg, chatInput.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, false, JSON.stringify(suggestionsObj));
|
2021-05-18 17:17:04 +00:00
|
|
|
if(event) event.accepted = true
|
|
|
|
sendMessageSound.stop();
|
|
|
|
Qt.callLater(sendMessageSound.play);
|
|
|
|
|
|
|
|
chatInput.textInput.clear();
|
|
|
|
chatInput.textInput.textFormat = TextEdit.PlainText;
|
|
|
|
chatInput.textInput.textFormat = TextEdit.RichText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EmptyChat {}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: txModalLoader
|
2020-11-03 10:29:56 +00:00
|
|
|
function close() {
|
|
|
|
if (!this.item) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.item.close()
|
|
|
|
this.closed()
|
|
|
|
}
|
|
|
|
function closed() {
|
|
|
|
this.sourceComponent = undefined
|
|
|
|
}
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: cmpSendTransactionNoEns
|
|
|
|
ChatCommandModal {
|
|
|
|
id: sendTransactionNoEns
|
2020-11-03 10:29:56 +00:00
|
|
|
onClosed: {
|
|
|
|
txModalLoader.closed()
|
|
|
|
}
|
2020-10-28 07:44:09 +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
|
2021-06-17 22:09:00 +00:00
|
|
|
alias: chatsModel.channelView.activeChannel.alias,
|
|
|
|
identicon: chatsModel.channelView.activeChannel.identicon,
|
|
|
|
name: chatsModel.channelView.activeChannel.name,
|
2020-10-28 07:44:09 +00:00
|
|
|
type: RecipientSelector.Type.Contact
|
|
|
|
}
|
|
|
|
}
|
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
|
|
|
selectRecipient.readOnly: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component {
|
|
|
|
id: cmpReceiveTransaction
|
|
|
|
ChatCommandModal {
|
|
|
|
id: receiveTransaction
|
2020-11-03 10:29:56 +00:00
|
|
|
onClosed: {
|
|
|
|
txModalLoader.closed()
|
|
|
|
}
|
2020-10-28 07:44:09 +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
|
2021-06-17 22:09:00 +00:00
|
|
|
alias: chatsModel.channelView.activeChannel.alias,
|
|
|
|
identicon: chatsModel.channelView.activeChannel.identicon,
|
|
|
|
name: chatsModel.channelView.activeChannel.name,
|
2020-10-28 07:44:09 +00:00
|
|
|
type: RecipientSelector.Type.Contact
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
|
|
|
selectRecipient.readOnly: true
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|
2020-05-26 18:16:07 +00:00
|
|
|
}
|
2020-10-28 07:44:09 +00:00
|
|
|
Component {
|
|
|
|
id: cmpSendTransactionWithEns
|
|
|
|
SendModal {
|
|
|
|
id: sendTransactionWithEns
|
|
|
|
onOpened: {
|
2021-06-08 12:48:31 +00:00
|
|
|
walletModel.gasView.getGasPricePredictions()
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
2020-11-03 10:29:56 +00:00
|
|
|
onClosed: {
|
|
|
|
txModalLoader.closed()
|
|
|
|
}
|
2020-10-28 07:44:09 +00:00
|
|
|
selectRecipient.readOnly: true
|
|
|
|
selectRecipient.selectedRecipient: {
|
|
|
|
return {
|
|
|
|
address: "",
|
2021-06-17 22:09:00 +00:00
|
|
|
alias: chatsModel.channelView.activeChannel.alias,
|
|
|
|
identicon: chatsModel.channelView.activeChannel.identicon,
|
|
|
|
name: chatsModel.channelView.activeChannel.name,
|
2020-10-29 23:08:07 +00:00
|
|
|
type: RecipientSelector.Type.Contact,
|
2020-10-28 07:44:09 +00:00
|
|
|
ensVerified: true
|
|
|
|
}
|
|
|
|
}
|
2020-10-29 23:08:07 +00:00
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
2020-09-29 09:06:57 +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
|
|
|
##^##*/
|