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
|
2021-07-14 12:35:37 +00:00
|
|
|
import Qt.labs.platform 1.1
|
2021-07-06 09:42:51 +00:00
|
|
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Popups 0.1
|
|
|
|
|
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
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
Item {
|
2020-07-10 15:37:23 +00:00
|
|
|
id: chatColumnLayout
|
2021-07-16 15:02:47 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.minimumWidth: 300
|
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-30 18:46:26 +00:00
|
|
|
property bool showUsers: false
|
2021-04-28 15:30:41 +00:00
|
|
|
property var doNotShowAddToContactBannerToThose: ([])
|
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-18 17:17:04 +00:00
|
|
|
property alias input: chatInput
|
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 var suggestionsObj: ([])
|
|
|
|
property Timer timer: Timer { }
|
|
|
|
property var onActivated: function () {
|
|
|
|
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
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 = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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-07-16 15:02:47 +00:00
|
|
|
function positionAtMessage(messageId) {
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].item.scrollToMessage(messageId)
|
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-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
|
|
|
|
}
|
|
|
|
|
|
|
|
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-07-21 10:33:13 +00:00
|
|
|
return chatsModel.channelView.activeChannel.description
|
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:
|
|
|
|
openPopup(groupInfoPopupComponent, {channelType: GroupInfoPopup.ChannelType.ActiveChannel})
|
|
|
|
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-07-16 15:02:47 +00:00
|
|
|
membersButton.visible: appSettings.showOnlineUsers && chatsModel.channelView.activeChannel.chatType !== Constants.chatTypeOneToOne
|
|
|
|
notificationButton.visible: appSettings.isActivityCenterEnabled
|
|
|
|
notificationCount: chatsModel.activityNotificationList.unreadCount
|
2021-07-06 09:42:51 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
onSearchButtonClicked: searchPopup.open()
|
|
|
|
SearchPopup {
|
|
|
|
id: searchPopup
|
|
|
|
}
|
2021-07-12 17:42:40 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
onMembersButtonClicked: showUsers = !showUsers
|
|
|
|
onNotificationButtonClicked: activityCenter.open()
|
2021-07-06 09:42:51 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
popupMenu: ChatContextMenu {
|
|
|
|
openHandler: {
|
|
|
|
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-07-16 15:02:47 +00:00
|
|
|
AddToContactBanner {
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
Layout.fillWidth: true
|
2020-07-15 16:19:25 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackLayoutChatMessages
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
clip: true
|
|
|
|
Repeater {
|
|
|
|
model: chatsModel.messageView
|
|
|
|
Loader {
|
|
|
|
active: false
|
|
|
|
sourceComponent: ChatMessages {
|
|
|
|
messageList: model.messages
|
|
|
|
currentTime: chatColumnLayout.currentTime
|
|
|
|
messageContextMenuInst: MessageContextMenu {
|
|
|
|
reactionModel: EmojiReactions { }
|
|
|
|
}
|
|
|
|
}
|
2020-07-15 16:19:25 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-28 15:30:41 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
Connections {
|
|
|
|
target: chatsModel.channelView
|
|
|
|
onActiveChannelChanged: {
|
|
|
|
stackLayoutChatMessages.currentIndex = chatsModel.messageView.getMessageListIndex(chatsModel.channelView.activeChannelIndex)
|
|
|
|
if(stackLayoutChatMessages.currentIndex > -1 && !stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].active){
|
|
|
|
stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].active = true;
|
|
|
|
}
|
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-07-16 15:02:47 +00:00
|
|
|
chatInput.suggestions.hide();
|
|
|
|
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
populateSuggestions();
|
2021-02-22 18:09:26 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
Connections {
|
|
|
|
target: chatsModel.messageView
|
|
|
|
onMessagePushed: {
|
|
|
|
addSuggestionFromMessageList(messageIndex);
|
|
|
|
}
|
2021-02-03 20:13:05 +00:00
|
|
|
}
|
2021-06-17 22:09:00 +00:00
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
Connections {
|
|
|
|
target: profileModel
|
|
|
|
onContactsChanged: {
|
|
|
|
populateSuggestions();
|
|
|
|
}
|
2020-07-14 11:40:58 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 15:02:47 +00:00
|
|
|
ChatRequestMessage {
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
2021-05-07 06:26:58 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 15:02:47 +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-07-16 15:02:47 +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-07-16 15:02:47 +00:00
|
|
|
Component {
|
|
|
|
id: loadingIndicator
|
|
|
|
LoadingAnimation { }
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusChatInput {
|
|
|
|
id: chatInput
|
|
|
|
visible: {
|
|
|
|
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
|
|
|
|
return chatsModel.channelView.activeChannel.isMember
|
|
|
|
}
|
|
|
|
if (chatsModel.channelView.activeChannel.chatType === Constants.chatTypeOneToOne) {
|
2021-07-20 14:22:32 +00:00
|
|
|
return isContact
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
|
|
|
const community = chatsModel.communities.activeCommunity
|
|
|
|
return !community.active ||
|
|
|
|
community.access === Constants.communityChatPublicAccess ||
|
|
|
|
community.admin ||
|
|
|
|
chatsModel.channelView.activeChannel.canPost
|
|
|
|
}
|
|
|
|
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
|
|
|
|
chatType: chatsModel.channelView.activeChannel.chatType
|
|
|
|
onSendTransactionCommandButtonClicked: {
|
|
|
|
if (chatsModel.channelView.activeChannel.ensVerified) {
|
|
|
|
txModalLoader.sourceComponent = cmpSendTransactionWithEns
|
|
|
|
} else {
|
|
|
|
txModalLoader.sourceComponent = cmpSendTransactionNoEns
|
|
|
|
}
|
|
|
|
txModalLoader.item.open()
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
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)
|
|
|
|
chatsModel.messageView.sendMessage(msg, chatInput.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType, false, JSON.stringify(suggestionsObj));
|
|
|
|
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-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: {
|
|
|
|
walletModel.gasView.getGasPricePredictions()
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
onContactBlocked: {
|
|
|
|
chatsModel.messageView.removeMessagesByUserId(publicKey)
|
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-16 15:02:47 +00:00
|
|
|
onMessageNotificationPushed: function(chatId, msg, contentType, chatType, timestamp, identicon, username, hasMention, isAddedContact, channelName) {
|
|
|
|
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
|
|
|
|
if (appSettings.useOSNotifications && systemTray.supportsMessages) {
|
|
|
|
systemTray.showMessage(name,
|
|
|
|
message,
|
|
|
|
SystemTrayIcon.NoIcon,
|
|
|
|
Constants.notificationPopupTTL)
|
|
|
|
} else {
|
|
|
|
notificationWindow.notifyUser(chatId, name, message, chatType, identicon, chatColumnLayout.clickOnNotification)
|
|
|
|
}
|
2021-07-14 12:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
|
|
|
|
}
|
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
|
|
|
##^##*/
|