96 lines
3.3 KiB
QML
96 lines
3.3 KiB
QML
|
import QtQuick 2.13
|
||
|
import "../../../../../imports"
|
||
|
import "../../../../../shared"
|
||
|
import "../../../../../shared/status"
|
||
|
import "../../components"
|
||
|
|
||
|
Item {
|
||
|
property alias chatInput: chatInput
|
||
|
|
||
|
id: inputArea
|
||
|
height: chatInput.height
|
||
|
|
||
|
Connections {
|
||
|
target: chatsModel
|
||
|
onLoadingMessagesChanged:
|
||
|
if(value){
|
||
|
loadingMessagesIndicator.active = true
|
||
|
} else {
|
||
|
timer.setTimeout(function(){
|
||
|
loadingMessagesIndicator.active = false;
|
||
|
}, 5000);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Loader {
|
||
|
id: loadingMessagesIndicator
|
||
|
active: chatsModel.loadingMessages
|
||
|
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: {
|
||
|
const community = chatsModel.communities.activeCommunity
|
||
|
if (chatsModel.activeChannel.chatType === Constants.chatTypePrivateGroupChat) {
|
||
|
return chatsModel.activeChannel.isMember
|
||
|
}
|
||
|
return !community.active ||
|
||
|
community.access === Constants.communityChatPublicAccess ||
|
||
|
community.admin ||
|
||
|
chatsModel.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.activeChannel.chatType
|
||
|
onSendTransactionCommandButtonClicked: {
|
||
|
if (chatsModel.activeChannel.ensVerified) {
|
||
|
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)
|
||
|
chatsModel.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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|