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-12-09 12:53:40 +00:00
|
|
|
import Qt.labs.qmlmodels 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
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
|
|
|
import shared.controls 1.0
|
2021-10-28 20:23:30 +00:00
|
|
|
import shared.views.chat 1.0
|
2020-05-25 20:34:26 +00:00
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
import "../helpers"
|
|
|
|
import "../controls"
|
|
|
|
import "../popups"
|
|
|
|
import "../panels"
|
|
|
|
import "../../Wallet"
|
2021-07-16 15:02:47 +00:00
|
|
|
|
|
|
|
Item {
|
2021-10-21 22:39:53 +00:00
|
|
|
id: root
|
2021-07-22 14:53:19 +00:00
|
|
|
anchors.fill: parent
|
2021-12-01 16:47:57 +00:00
|
|
|
|
|
|
|
// Important: we have parent module in this context only cause qml components
|
2021-12-09 12:53:40 +00:00
|
|
|
// don't follow struct we have on the backend.
|
2021-12-01 16:47:57 +00:00
|
|
|
property var parentModule
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
property var rootStore
|
2022-01-04 12:06:05 +00:00
|
|
|
property var contactsStore
|
2022-01-13 21:41:43 +00:00
|
|
|
property var chatSectionModule
|
2022-01-04 12:06:05 +00:00
|
|
|
|
2021-12-21 09:26:13 +00:00
|
|
|
property Component pinnedMessagesPopupComponent
|
2021-11-26 15:37:57 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
//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-12-16 20:02:58 +00:00
|
|
|
property string activeChatId: parentModule && parentModule.activeItem.id
|
|
|
|
property string activeSubItemId: parentModule && parentModule.activeItem.activeSubItem.id
|
|
|
|
property string activeChatType: parentModule && parentModule.activeItem.type
|
2021-05-26 17:36:24 +00:00
|
|
|
property string currentNotificationChatId
|
|
|
|
property string currentNotificationCommunityId
|
2021-07-16 15:02:47 +00:00
|
|
|
property var currentTime: 0
|
|
|
|
property var idMap: ({})
|
2021-12-08 21:20:43 +00:00
|
|
|
property bool stickersLoaded: false
|
2021-07-16 15:02:47 +00:00
|
|
|
property Timer timer: Timer { }
|
2021-07-22 14:53:19 +00:00
|
|
|
property var userList
|
2021-09-21 12:26:32 +00:00
|
|
|
|
2022-01-11 23:16:17 +00:00
|
|
|
property var contactDetails: Utils.getContactDetailsAsJson(root.activeChatId)
|
|
|
|
property bool isContact: root.contactDetails.isContact
|
2022-01-04 12:06:05 +00:00
|
|
|
property bool contactRequestReceived: root.contactDetails.requestReceived
|
|
|
|
|
2021-11-10 08:09:31 +00:00
|
|
|
signal openAppSearch()
|
2021-12-08 21:20:43 +00:00
|
|
|
signal openStickerPackPopup(string stickerPackId)
|
2021-11-10 08:09:31 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// function hideChatInputExtendedArea () {
|
|
|
|
// if(stackLayoutChatMessages.currentIndex >= 0 && stackLayoutChatMessages.currentIndex < stackLayoutChatMessages.children.length)
|
|
|
|
// stackLayoutChatMessages.children[stackLayoutChatMessages.currentIndex].chatInput.hideExtendedArea()
|
|
|
|
// }
|
2021-05-25 19:38:18 +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-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// let replyMessageIndex = root.rootStore.chatsModelInst.messageView.messageList.getMessageIndex(SelectedMessage.messageId);
|
|
|
|
// if (replyMessageIndex === -1) return;
|
|
|
|
// let userName = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "userName")
|
|
|
|
// let message = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "message")
|
|
|
|
// let identicon = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "identicon")
|
|
|
|
// let image = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "image")
|
|
|
|
// let sticker = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "sticker")
|
|
|
|
// let contentType = root.rootStore.chatsModelInst.messageView.messageList.getMessageData(replyMessageIndex, "contentType")
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// 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) {
|
2021-12-14 16:11:31 +00:00
|
|
|
amount = globalUtils.eth2Wei(amount.toString(), tokenDecimals)
|
2021-12-23 20:46:58 +00:00
|
|
|
|
|
|
|
parentModule.prepareChatContentModuleForChatId(activeChatId)
|
|
|
|
let chatContentModule = parentModule.getChatContentModule()
|
|
|
|
chatContentModule.inputAreaModule.requestAddress(address,
|
|
|
|
amount,
|
|
|
|
tokenAddress)
|
2020-07-20 17:04:33 +00:00
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
function requestTransaction(address, amount, tokenAddress, tokenDecimals = 18) {
|
2021-12-23 20:46:58 +00:00
|
|
|
amount = globalUtils.eth2Wei(amount.toString(), tokenDecimals)
|
|
|
|
|
|
|
|
|
|
|
|
parentModule.prepareChatContentModuleForChatId(activeChatId)
|
|
|
|
let chatContentModule = parentModule.getChatContentModule()
|
|
|
|
chatContentModule.inputAreaModule.request(address,
|
|
|
|
amount,
|
|
|
|
tokenAddress)
|
2020-07-20 17:04:33 +00:00
|
|
|
}
|
2020-09-29 09:06:57 +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: {
|
2021-10-21 22:39:53 +00:00
|
|
|
root.currentTime = Date.now()
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-04-07 18:26:03 +00:00
|
|
|
}
|
2021-06-10 19:20:43 +00:00
|
|
|
|
2021-12-08 21:20:43 +00:00
|
|
|
MessageContextMenuView {
|
|
|
|
id: contextmenu
|
2022-01-19 15:59:08 +00:00
|
|
|
store: root.rootStore
|
2021-12-08 21:20:43 +00:00
|
|
|
reactionModel: root.rootStore.emojiReactionsModel
|
|
|
|
}
|
2022-02-09 09:43:23 +00:00
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
EmptyChatPanel {
|
2022-01-25 15:22:35 +00:00
|
|
|
anchors.fill: parent
|
2022-01-20 12:15:36 +00:00
|
|
|
visible: root.activeChatId === ""
|
2022-01-28 08:19:49 +00:00
|
|
|
rootStore: root.rootStore
|
2022-01-20 12:15:36 +00:00
|
|
|
onShareChatKeyClicked: Global.openProfilePopup(userProfile.pubKey);
|
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
// This is kind of a solution for applying backend refactored changes with the minimal qml changes.
|
|
|
|
// The best would be if we made qml to follow the struct we have on the backend side.
|
|
|
|
Repeater {
|
|
|
|
model: parentModule && parentModule.model
|
|
|
|
delegate: delegateChooser
|
|
|
|
|
|
|
|
DelegateChooser {
|
|
|
|
id: delegateChooser
|
|
|
|
role: "type"
|
|
|
|
DelegateChoice { // In case of category
|
2022-01-28 13:49:56 +00:00
|
|
|
roleValue: Constants.chatType.unknown
|
2022-01-20 12:15:36 +00:00
|
|
|
delegate: Repeater {
|
|
|
|
model: {
|
|
|
|
if (!subItems) {
|
|
|
|
console.error("We got a category with no subitems. It is possible that the channel had a type unknown")
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
return subItems
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
delegate: ChatContentView {
|
2022-01-20 12:15:36 +00:00
|
|
|
width: parent.width
|
|
|
|
clip: true
|
|
|
|
height: {
|
|
|
|
// dynamically calculate the height of the view, if the active one is the current one
|
|
|
|
// then set the height to parent otherwise set it to 0
|
2022-01-28 12:05:17 +00:00
|
|
|
if(!chatContentModule)
|
|
|
|
return 0
|
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
let myChatId = chatContentModule.getMyChatId()
|
|
|
|
if(myChatId === root.activeChatId || myChatId === root.activeSubItemId)
|
|
|
|
return parent.height
|
2022-01-28 12:05:17 +00:00
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
return 0
|
2022-01-28 12:05:17 +00:00
|
|
|
}
|
2021-12-22 14:55:13 +00:00
|
|
|
rootStore: root.rootStore
|
2022-01-04 12:06:05 +00:00
|
|
|
contactsStore: root.contactsStore
|
2021-12-23 20:46:58 +00:00
|
|
|
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
|
|
|
receiveTransactionModal: cmpReceiveTransaction
|
|
|
|
sendTransactionWithEnsModal: cmpSendTransactionWithEns
|
2022-01-05 15:50:03 +00:00
|
|
|
stickersLoaded: root.stickersLoaded
|
2022-02-04 10:21:05 +00:00
|
|
|
isBlocked: model.blocked
|
2021-12-09 12:53:40 +00:00
|
|
|
Component.onCompleted: {
|
2022-01-20 12:15:36 +00:00
|
|
|
parentModule.prepareChatContentModuleForChatId(model.itemId)
|
2021-12-09 12:53:40 +00:00
|
|
|
chatContentModule = parentModule.getChatContentModule()
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-21 12:26:32 +00:00
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
DelegateChoice { // In all other cases
|
|
|
|
delegate: ChatContentView {
|
|
|
|
width: parent.width
|
|
|
|
clip: true
|
|
|
|
height: {
|
|
|
|
// dynamically calculate the height of the view, if the active one is the current one
|
|
|
|
// then set the height to parent otherwise set it to 0
|
2022-01-28 12:05:17 +00:00
|
|
|
if(!chatContentModule)
|
|
|
|
return 0
|
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
let myChatId = chatContentModule.getMyChatId()
|
|
|
|
if(myChatId === root.activeChatId || myChatId === root.activeSubItemId)
|
|
|
|
return parent.height
|
2022-01-28 12:05:17 +00:00
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
return 0
|
2022-02-09 09:43:23 +00:00
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
rootStore: root.rootStore
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
sendTransactionNoEnsModal: cmpSendTransactionNoEns
|
|
|
|
receiveTransactionModal: cmpReceiveTransaction
|
|
|
|
sendTransactionWithEnsModal: cmpSendTransactionWithEns
|
|
|
|
stickersLoaded: root.stickersLoaded
|
2022-02-04 10:21:05 +00:00
|
|
|
isBlocked: model.blocked
|
2022-01-20 12:15:36 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
parentModule.prepareChatContentModuleForChatId(itemId)
|
|
|
|
chatContentModule = parentModule.getChatContentModule()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-09 11:11:04 +00:00
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
ChatRequestMessagePanel {
|
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.bottomMargin: Style.current.bigPadding
|
|
|
|
isContact: root.isContact
|
2022-01-20 12:15:36 +00:00
|
|
|
visible: root.activeChatType === Constants.chatType.oneToOne && (!root.isContact /*|| !contactRequestReceived*/)
|
2021-12-09 12:53:40 +00:00
|
|
|
onAddContactClicked: {
|
2021-12-16 20:02:58 +00:00
|
|
|
root.rootStore.addContact(root.activeChatId);
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2021-12-01 16:47:57 +00:00
|
|
|
}
|
2021-05-18 17:17:04 +00:00
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
Component {
|
|
|
|
id: cmpSendTransactionNoEns
|
|
|
|
ChatCommandModal {
|
|
|
|
id: sendTransactionNoEns
|
|
|
|
store: root.rootStore
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
isContact: root.isContact
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
sendChatCommand: root.requestAddressForTransaction
|
|
|
|
isRequested: false
|
|
|
|
//% "Send"
|
|
|
|
commandTitle: qsTrId("command-button-send")
|
|
|
|
header.title: commandTitle
|
|
|
|
//% "Request Address"
|
|
|
|
finalButtonLabel: qsTrId("request-address")
|
|
|
|
selectRecipient.selectedRecipient: {
|
|
|
|
parentModule.prepareChatContentModuleForChatId(activeChatId)
|
|
|
|
let chatContentModule = parentModule.getChatContentModule()
|
|
|
|
return {
|
|
|
|
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
|
|
|
|
alias: chatContentModule.chatDetails.name, // Do we need the alias for real or name works?
|
|
|
|
identicon: chatContentModule.chatDetails.icon,
|
|
|
|
name: chatContentModule.chatDetails.name,
|
2022-02-09 00:04:49 +00:00
|
|
|
type: RecipientSelector.Type.Contact,
|
|
|
|
ensVerified: true
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
|
|
|
selectRecipient.readOnly: true
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
Component {
|
|
|
|
id: cmpReceiveTransaction
|
|
|
|
ChatCommandModal {
|
|
|
|
id: receiveTransaction
|
|
|
|
store: root.rootStore
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
isContact: root.isContact
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
sendChatCommand: root.requestTransaction
|
|
|
|
isRequested: true
|
|
|
|
//% "Request"
|
|
|
|
commandTitle: qsTrId("wallet-request")
|
|
|
|
header.title: commandTitle
|
|
|
|
//% "Request"
|
|
|
|
finalButtonLabel: qsTrId("wallet-request")
|
|
|
|
selectRecipient.selectedRecipient: {
|
|
|
|
parentModule.prepareChatContentModuleForChatId(activeChatId)
|
|
|
|
let chatContentModule = parentModule.getChatContentModule()
|
|
|
|
return {
|
|
|
|
address: Constants.zeroAddress, // Setting as zero address since we don't have the address yet
|
|
|
|
alias: chatContentModule.chatDetails.name, // Do we need the alias for real or name works?
|
|
|
|
identicon: chatContentModule.chatDetails.icon,
|
|
|
|
name: chatContentModule.chatDetails.name,
|
|
|
|
type: RecipientSelector.Type.Contact
|
2021-05-18 17:17:04 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
|
|
|
selectRecipient.readOnly: true
|
2020-10-28 07:44:09 +00:00
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
}
|
2020-10-28 07:44:09 +00:00
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
Component {
|
|
|
|
id: cmpSendTransactionWithEns
|
|
|
|
SendModal {
|
|
|
|
id: sendTransactionWithEns
|
|
|
|
store: root.rootStore
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
onOpened: {
|
|
|
|
// Not Refactored Yet
|
2021-12-13 14:24:21 +00:00
|
|
|
// root.rootStore.walletModelInst.gasView.getGasPrice()
|
2022-01-20 12:15:36 +00:00
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
destroy()
|
|
|
|
}
|
|
|
|
isContact: root.isContact
|
|
|
|
selectRecipient.readOnly: true
|
|
|
|
selectRecipient.selectedRecipient: {
|
|
|
|
parentModule.prepareChatContentModuleForChatId(activeChatId)
|
|
|
|
let chatContentModule = parentModule.getChatContentModule()
|
|
|
|
|
|
|
|
return {
|
|
|
|
address: "",
|
|
|
|
alias: chatContentModule.chatDetails.name, // Do we need the alias for real or name works?
|
|
|
|
identicon: chatContentModule.chatDetails.icon,
|
|
|
|
name: chatContentModule.chatDetails.name,
|
|
|
|
type: RecipientSelector.Type.Contact,
|
|
|
|
ensVerified: true
|
2021-07-16 15:02:47 +00:00
|
|
|
}
|
2020-11-03 10:29:56 +00:00
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
selectRecipient.selectedType: RecipientSelector.Type.Contact
|
2020-11-03 10:29:56 +00:00
|
|
|
}
|
2022-01-20 12:15:36 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
2022-01-20 12:15:36 +00:00
|
|
|
ActivityCenterPopup {
|
|
|
|
id: activityCenter
|
|
|
|
height: root.height - 56 * 2 // TODO get screen size // Taken from old code top bar height was fixed there to 56
|
|
|
|
y: 56
|
|
|
|
store: root.rootStore
|
|
|
|
chatSectionModule: root.chatSectionModule
|
2022-02-01 13:10:24 +00:00
|
|
|
messageContextMenu: contextmenu
|
2022-01-20 12:15:36 +00:00
|
|
|
}
|
2021-07-16 15:02:47 +00:00
|
|
|
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// Connections {
|
|
|
|
// target: root.rootStore.chatsModelInst.stickers
|
|
|
|
// onTransactionWasSent: {
|
|
|
|
// //% "Transaction pending..."
|
|
|
|
// toastMessage.title = qsTr("Transaction pending...")
|
|
|
|
// toastMessage.source = Style.svg("loading")
|
|
|
|
// toastMessage.iconColor = Style.current.primary
|
|
|
|
// toastMessage.iconRotates = true
|
|
|
|
// toastMessage.link = `${walletModel.utilsView.etherscanLink}/${txResult}`
|
|
|
|
// toastMessage.open()
|
|
|
|
// }
|
|
|
|
// onTransactionCompleted: {
|
|
|
|
// toastMessage.title = !success ?
|
|
|
|
// //% "Could not buy Stickerpack"
|
|
|
|
// qsTrId("could-not-buy-stickerpack")
|
|
|
|
// :
|
|
|
|
// //% "Stickerpack bought successfully"
|
|
|
|
// qsTrId("stickerpack-bought-successfully");
|
|
|
|
// if (success) {
|
|
|
|
// toastMessage.source = Style.svg("check-circle")
|
|
|
|
// toastMessage.iconColor = Style.current.success
|
|
|
|
// } else {
|
|
|
|
// toastMessage.source = Style.svg("block-icon")
|
|
|
|
// toastMessage.iconColor = Style.current.danger
|
|
|
|
// }
|
|
|
|
|
|
|
|
// toastMessage.link = `${walletModel.utilsView.etherscanLink}/${txHash}`
|
|
|
|
// toastMessage.open()
|
|
|
|
// }
|
|
|
|
// }
|
2020-05-25 20:34:26 +00:00
|
|
|
}
|