2023-04-19 17:31:18 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQml 2.15
|
2023-04-21 15:05:34 +00:00
|
|
|
import QtQuick.Controls 2.15
|
2023-04-26 09:20:17 +00:00
|
|
|
import QtQuick.Layouts 1.15
|
2021-12-09 12:53:40 +00:00
|
|
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2022-03-07 14:56:05 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2021-12-09 12:53:40 +00:00
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
|
|
|
import shared.controls 1.0
|
|
|
|
import shared.views.chat 1.0
|
|
|
|
|
|
|
|
import "../helpers"
|
|
|
|
import "../controls"
|
|
|
|
import "../popups"
|
|
|
|
import "../panels"
|
|
|
|
import "../../Wallet"
|
|
|
|
import "../stores"
|
|
|
|
|
|
|
|
ColumnLayout {
|
2022-05-10 16:04:25 +00:00
|
|
|
id: root
|
2022-07-21 16:16:25 +00:00
|
|
|
objectName: "chatContentViewColumn"
|
2021-12-09 12:53:40 +00:00
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
// Important:
|
|
|
|
// Each chat/channel has its own ChatContentModule
|
|
|
|
property var chatContentModule
|
2022-05-10 16:04:25 +00:00
|
|
|
property var chatSectionModule
|
2021-12-22 14:55:13 +00:00
|
|
|
property var rootStore
|
2022-01-04 12:06:05 +00:00
|
|
|
property var contactsStore
|
2022-02-28 20:14:04 +00:00
|
|
|
property bool isActiveChannel: false
|
2023-04-18 18:23:57 +00:00
|
|
|
property string chatId
|
2023-04-27 14:21:41 +00:00
|
|
|
property int chatType: Constants.chatType.unknown
|
2023-03-10 17:33:26 +00:00
|
|
|
|
2023-04-17 20:43:23 +00:00
|
|
|
readonly property alias chatMessagesLoader: chatMessagesLoader
|
|
|
|
|
2022-03-07 14:56:05 +00:00
|
|
|
property var emojiPopup
|
2022-11-14 20:21:00 +00:00
|
|
|
property var stickersPopup
|
2022-02-08 12:08:02 +00:00
|
|
|
property UsersStore usersStore: UsersStore {}
|
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
onChatContentModuleChanged: if (!!chatContentModule) {
|
2022-05-10 16:04:25 +00:00
|
|
|
root.usersStore.usersModule = root.chatContentModule.usersModule
|
2022-02-08 12:08:02 +00:00
|
|
|
}
|
|
|
|
|
2022-05-10 16:04:25 +00:00
|
|
|
signal openAppSearch()
|
2022-02-14 23:27:23 +00:00
|
|
|
signal openStickerPackPopup(string stickerPackId)
|
2021-12-09 12:53:40 +00:00
|
|
|
|
2021-12-23 20:46:58 +00:00
|
|
|
property Component sendTransactionNoEnsModal
|
|
|
|
property Component receiveTransactionModal
|
|
|
|
property Component sendTransactionWithEnsModal
|
|
|
|
|
2022-02-04 10:21:05 +00:00
|
|
|
property bool isBlocked: false
|
2023-04-28 10:28:19 +00:00
|
|
|
property bool isUserAllowedToSendMessage: root.rootStore.isUserAllowedToSendMessage
|
|
|
|
property string chatInputPlaceholder: root.rootStore.chatInputPlaceHolderText
|
2022-01-05 15:50:03 +00:00
|
|
|
property bool stickersLoaded: false
|
|
|
|
|
2023-01-06 15:43:54 +00:00
|
|
|
Loader {
|
2021-12-09 12:53:40 +00:00
|
|
|
Layout.fillWidth: true
|
2023-01-06 15:43:54 +00:00
|
|
|
active: root.isBlocked
|
|
|
|
visible: active
|
|
|
|
sourceComponent: StatusBanner {
|
|
|
|
type: StatusBanner.Type.Danger
|
|
|
|
statusText: qsTr("Blocked")
|
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2023-04-17 20:43:23 +00:00
|
|
|
readonly property var messageStore: MessageStore {
|
2022-09-30 14:36:49 +00:00
|
|
|
messageModule: chatContentModule ? chatContentModule.messagesModule : null
|
2022-05-10 16:04:25 +00:00
|
|
|
chatSectionModule: root.rootStore.chatCommunitySectionModule
|
2021-12-14 14:19:55 +00:00
|
|
|
}
|
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
2021-12-20 14:21:35 +00:00
|
|
|
|
fix(contacts): fix inconsistency when banning or unbanning contact
Fixes #10501
The problem was that didn't have access to the updated contact from status-go after banning or unbanning, so we just changed the banned property, but there is more that gets changed in the backend, like `removed` being set to `true` as well.
With this fix, when you unban someone, you go back to a fresh start, as **non** contact, so you need to send a request again. That was the state you got if you restarted the app, so "re-sync" the state with status-go.
Another issue was on the frontend (QML). When banned, and after restarting to get the right state, the unban button would be disabled and the Add contact request button would show, which is not good. We only want to send requests when unbanned.
2023-05-31 19:09:37 +00:00
|
|
|
readonly property string blockedText: qsTr("This user has been blocked.")
|
|
|
|
|
2023-05-19 16:07:50 +00:00
|
|
|
function showReplyArea(messageId) {
|
|
|
|
let obj = messageStore.getMessageByIdAsJson(messageId)
|
|
|
|
if (!obj) {
|
|
|
|
return
|
2023-04-19 17:31:18 +00:00
|
|
|
}
|
2023-05-19 16:07:50 +00:00
|
|
|
if (inputAreaLoader.item) {
|
|
|
|
inputAreaLoader.item.chatInput.showReplyArea(messageId, obj.senderDisplayName, obj.messageText, obj.contentType, obj.messageImage, obj.albumMessageImages, obj.albumImagesCount, obj.sticker)
|
2022-04-12 15:15:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-14 14:19:55 +00:00
|
|
|
}
|
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
clip: true
|
|
|
|
|
2023-04-17 20:43:23 +00:00
|
|
|
Loader {
|
|
|
|
id: chatMessagesLoader
|
2021-12-09 12:53:40 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2023-04-17 20:43:23 +00:00
|
|
|
|
|
|
|
sourceComponent: ChatMessagesView {
|
|
|
|
chatContentModule: root.chatContentModule
|
|
|
|
rootStore: root.rootStore
|
|
|
|
contactsStore: root.contactsStore
|
|
|
|
messageStore: root.messageStore
|
|
|
|
emojiPopup: root.emojiPopup
|
|
|
|
stickersPopup: root.stickersPopup
|
|
|
|
usersStore: root.usersStore
|
|
|
|
stickersLoaded: root.stickersLoaded
|
2023-05-19 16:07:50 +00:00
|
|
|
chatId: root.chatId
|
2023-04-21 15:05:34 +00:00
|
|
|
isOneToOne: root.chatType === Constants.chatType.oneToOne
|
fix(contacts): fix inconsistency when banning or unbanning contact
Fixes #10501
The problem was that didn't have access to the updated contact from status-go after banning or unbanning, so we just changed the banned property, but there is more that gets changed in the backend, like `removed` being set to `true` as well.
With this fix, when you unban someone, you go back to a fresh start, as **non** contact, so you need to send a request again. That was the state you got if you restarted the app, so "re-sync" the state with status-go.
Another issue was on the frontend (QML). When banned, and after restarting to get the right state, the unban button would be disabled and the Add contact request button would show, which is not good. We only want to send requests when unbanned.
2023-05-31 19:09:37 +00:00
|
|
|
isContactBlocked: root.isBlocked
|
2023-04-28 10:28:19 +00:00
|
|
|
isChatBlocked: root.isBlocked || !root.isUserAllowedToSendMessage
|
2023-04-17 20:43:23 +00:00
|
|
|
channelEmoji: !chatContentModule ? "" : (chatContentModule.chatDetails.emoji || "")
|
|
|
|
isActiveChannel: root.isActiveChannel
|
2023-05-19 16:07:50 +00:00
|
|
|
onShowReplyArea: (messageId, senderId) => {
|
|
|
|
d.showReplyArea(messageId)
|
2022-01-12 12:55:26 +00:00
|
|
|
}
|
2023-04-17 20:43:23 +00:00
|
|
|
onOpenStickerPackPopup: {
|
|
|
|
root.openStickerPackPopup(stickerPackId);
|
|
|
|
}
|
2023-05-19 16:07:50 +00:00
|
|
|
onEditModeChanged: {
|
|
|
|
if (!editModeOn && inputAreaLoader.item)
|
|
|
|
inputAreaLoader.item.chatInput.forceInputActiveFocus()
|
|
|
|
}
|
2022-01-12 12:55:26 +00:00
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
Loader {
|
|
|
|
id: inputAreaLoader
|
|
|
|
|
2021-12-09 12:53:40 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
|
|
|
Layout.fillWidth: true
|
2022-07-05 10:12:27 +00:00
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
active: root.isActiveChannel
|
|
|
|
asynchronous: true
|
2022-09-22 07:13:03 +00:00
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
property string preservedText
|
|
|
|
Binding on preservedText {
|
|
|
|
when: inputAreaLoader.item != null
|
|
|
|
value: inputAreaLoader.item ? inputAreaLoader.item.chatInput.textInput.text : inputAreaLoader.preservedText
|
|
|
|
restoreMode: Binding.RestoreNone
|
|
|
|
delayed: true
|
|
|
|
}
|
2022-07-15 10:32:26 +00:00
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
// FIXME: `StatusChatInput` is way too heavy
|
|
|
|
// see: https://github.com/status-im/status-desktop/pull/10343#issuecomment-1515103756
|
|
|
|
sourceComponent: Item {
|
|
|
|
id: inputArea
|
|
|
|
implicitHeight: chatInput.implicitHeight
|
|
|
|
+ chatInput.anchors.topMargin
|
|
|
|
+ chatInput.anchors.bottomMargin
|
|
|
|
|
|
|
|
readonly property alias chatInput: chatInput
|
|
|
|
|
|
|
|
StatusChatInput {
|
|
|
|
id: chatInput
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: Style.current.smallPadding
|
|
|
|
|
fix(contacts): fix inconsistency when banning or unbanning contact
Fixes #10501
The problem was that didn't have access to the updated contact from status-go after banning or unbanning, so we just changed the banned property, but there is more that gets changed in the backend, like `removed` being set to `true` as well.
With this fix, when you unban someone, you go back to a fresh start, as **non** contact, so you need to send a request again. That was the state you got if you restarted the app, so "re-sync" the state with status-go.
Another issue was on the frontend (QML). When banned, and after restarting to get the right state, the unban button would be disabled and the Add contact request button would show, which is not good. We only want to send requests when unbanned.
2023-05-31 19:09:37 +00:00
|
|
|
// We enable the component if the contact is blocked, because if we disable it, the `Unban` button
|
|
|
|
// becomes disabled. All the local components inside already disable themselves when blocked
|
|
|
|
enabled: root.isBlocked ||
|
|
|
|
(root.rootStore.sectionDetails.joined && !root.rootStore.sectionDetails.amIBanned &&
|
|
|
|
root.isUserAllowedToSendMessage)
|
2023-04-19 17:31:18 +00:00
|
|
|
|
|
|
|
store: root.rootStore
|
|
|
|
usersStore: root.usersStore
|
|
|
|
|
|
|
|
textInput.text: inputAreaLoader.preservedText
|
fix(contacts): fix inconsistency when banning or unbanning contact
Fixes #10501
The problem was that didn't have access to the updated contact from status-go after banning or unbanning, so we just changed the banned property, but there is more that gets changed in the backend, like `removed` being set to `true` as well.
With this fix, when you unban someone, you go back to a fresh start, as **non** contact, so you need to send a request again. That was the state you got if you restarted the app, so "re-sync" the state with status-go.
Another issue was on the frontend (QML). When banned, and after restarting to get the right state, the unban button would be disabled and the Add contact request button would show, which is not good. We only want to send requests when unbanned.
2023-05-31 19:09:37 +00:00
|
|
|
textInput.placeholderText: root.isBlocked ? d.blockedText : root.chatInputPlaceholder
|
2023-04-19 17:31:18 +00:00
|
|
|
emojiPopup: root.emojiPopup
|
|
|
|
stickersPopup: root.stickersPopup
|
|
|
|
isContactBlocked: root.isBlocked
|
|
|
|
isActiveChannel: root.isActiveChannel
|
|
|
|
anchors.bottom: parent.bottom
|
2023-04-27 14:21:41 +00:00
|
|
|
chatType: root.chatType
|
|
|
|
suggestions.suggestionFilter.addSystemSuggestions: chatType === Constants.chatType.communityChat
|
2023-04-19 17:31:18 +00:00
|
|
|
|
|
|
|
Binding on chatInputPlaceholder {
|
|
|
|
when: root.isBlocked
|
fix(contacts): fix inconsistency when banning or unbanning contact
Fixes #10501
The problem was that didn't have access to the updated contact from status-go after banning or unbanning, so we just changed the banned property, but there is more that gets changed in the backend, like `removed` being set to `true` as well.
With this fix, when you unban someone, you go back to a fresh start, as **non** contact, so you need to send a request again. That was the state you got if you restarted the app, so "re-sync" the state with status-go.
Another issue was on the frontend (QML). When banned, and after restarting to get the right state, the unban button would be disabled and the Add contact request button would show, which is not good. We only want to send requests when unbanned.
2023-05-31 19:09:37 +00:00
|
|
|
value: d.blockedText
|
2023-04-19 17:31:18 +00:00
|
|
|
}
|
2022-09-22 07:13:03 +00:00
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
Binding on chatInputPlaceholder {
|
|
|
|
when: !root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned
|
|
|
|
value: qsTr("You need to join this community to send messages")
|
2022-01-11 23:16:17 +00:00
|
|
|
}
|
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
onSendTransactionCommandButtonClicked: {
|
|
|
|
if(!chatContentModule) {
|
|
|
|
console.debug("error on sending transaction command - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Utils.isEnsVerified(chatContentModule.getMyChatId())) {
|
|
|
|
Global.openPopup(root.sendTransactionWithEnsModal)
|
|
|
|
} else {
|
|
|
|
Global.openPopup(root.sendTransactionNoEnsModal)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onReceiveTransactionCommandButtonClicked: {
|
|
|
|
Global.openPopup(root.receiveTransactionModal)
|
|
|
|
}
|
|
|
|
onStickerSelected: {
|
|
|
|
root.rootStore.sendSticker(chatContentModule.getMyChatId(),
|
|
|
|
hashId,
|
|
|
|
chatInput.isReply ? chatInput.replyMessageId : "",
|
|
|
|
packId,
|
|
|
|
url)
|
2021-12-23 20:46:58 +00:00
|
|
|
}
|
2022-01-11 23:16:17 +00:00
|
|
|
|
2022-02-15 21:00:05 +00:00
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
onSendMessage: {
|
|
|
|
if (!chatContentModule) {
|
|
|
|
console.debug("error on sending message - chat content module is not set")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(root.rootStore.sendMessage(chatContentModule.getMyChatId(),
|
|
|
|
event,
|
|
|
|
chatInput.getTextWithPublicKeys(),
|
|
|
|
chatInput.isReply? chatInput.replyMessageId : "",
|
|
|
|
chatInput.fileUrlsAndSources
|
|
|
|
))
|
|
|
|
{
|
|
|
|
Global.playSendMessageSound()
|
|
|
|
|
|
|
|
chatInput.textInput.clear();
|
|
|
|
chatInput.textInput.textFormat = TextEdit.PlainText;
|
|
|
|
chatInput.textInput.textFormat = TextEdit.RichText;
|
|
|
|
}
|
2022-03-22 08:29:58 +00:00
|
|
|
}
|
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
onUnblockChat: {
|
|
|
|
chatContentModule.unblockChat()
|
2021-12-22 14:55:13 +00:00
|
|
|
}
|
2023-04-19 17:31:18 +00:00
|
|
|
onKeyUpPress: messageStore.setEditModeOnLastMessage(root.rootStore.userProfileInst.pubKey)
|
2022-02-24 12:15:02 +00:00
|
|
|
|
2023-04-19 17:31:18 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
Qt.callLater(() => {
|
|
|
|
forceInputActiveFocus()
|
|
|
|
textInput.cursorPosition = textInput.length
|
|
|
|
})
|
|
|
|
}
|
2022-02-24 12:15:02 +00:00
|
|
|
}
|
2021-12-09 12:53:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|