fix: incorrect mentions behavior when text contains emojies

This commit is contained in:
Richard Ramos 2020-08-03 10:01:47 -04:00
parent 397be0b0c0
commit cb92c1dc14
No known key found for this signature in database
GPG Key ID: 80D4B01265FDFE8F
5 changed files with 25 additions and 33 deletions

View File

@ -102,8 +102,6 @@ QtObject:
var m = self.replaceMentionsWithPubKeys(aliasMentions, contacts, message, (c => c.alias))
m = self.replaceMentionsWithPubKeys(ensMentions, contacts, m, (c => c.ensName))
m = self.replaceMentionsWithPubKeys(nameMentions, contacts, m, (c => c.ensName.split(".")[0]))
m = self.plainText(m)
self.status.chat.sendMessage(self.activeChannel.id, m, replyTo, contentType)
proc verifyMessageSent*(self: ChatsView, data: string) {.slot.} =

View File

@ -218,8 +218,8 @@ StackLayout {
position = nameLen
text = "@" + aliasName + " "
} else {
let left = currentText.substring(0, lastAtPosition)
let right = currentText.substring(lastAtPosition + 2)
let left = currentText.substring(0, lastAt)
let right = currentText.substring(lastAt + 1)
text = `${left} @${aliasName} ${right}`
}

View File

@ -8,6 +8,7 @@ import "../components"
Item {
property int iconPadding: 6
property var addToChat: function () {}
property var onSend: function () {}
id: chatButtonsContainer
@ -32,17 +33,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
onClicked: {
if(chatColumn.isImage){
chatsModel.sendImage(sendImageArea.image);
}
let msg = chatsModel.plainText(Emoji.deparse(txtData.text)).trim()
if(msg.length > 0){
chatsModel.sendMessage(msg, chatColumn.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType)
txtData.text = "";
}
chatColumn.hideExtendedArea();
onSend();
}
background: Rectangle {
color: parent.enabled ? Style.current.blue : Style.current.grey

View File

@ -32,25 +32,25 @@ Rectangle {
return msg
}
function sendMsg(event){
if(chatColumn.isImage){
chatsModel.sendImage(sendImageArea.image);
}
var msg = chatsModel.plainText(Emoji.deparse(txtData.text).trim()).trim()
if(msg.length > 0){
msg = interpretMessage(msg)
chatsModel.sendMessage(msg, chatColumn.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType);
txtData.text = "";
if(event) event.accepted = true
sendMessageSound.stop()
Qt.callLater(sendMessageSound.play);
}
chatColumn.hideExtendedArea();
}
function onEnter(event){
if (event.modifiers === Qt.NoModifier && (event.key === Qt.Key_Enter || event.key === Qt.Key_Return)) {
if(chatColumn.isImage){
chatsModel.sendImage(sendImageArea.image);
}
var msg = chatsModel.plainText(Emoji.deparse(txtData.text).trim()).trim()
if(msg.length > 0){
msg = interpretMessage(msg)
msg = Emoji.deparse(msg)
chatsModel.sendMessage(msg, chatColumn.isReply ? SelectedMessage.messageId : "", Utils.isOnlyEmoji(msg) ? Constants.emojiType : Constants.messageType);
txtData.text = "";
event.accepted = true
sendMessageSound.stop()
Qt.callLater(sendMessageSound.play);
}
chatColumn.hideExtendedArea();
sendMsg(event);
}
}
@ -104,6 +104,9 @@ Rectangle {
addToChat: function (text) {
txtData.insert(txtData.length, text)
}
onSend: function(){
sendMsg(false)
}
}
}
/*##^##

2
vendor/nimqml vendored

@ -1 +1 @@
Subproject commit fe3d330269e08cf6a296719fa2dd84e91c7ecfda
Subproject commit 57d6e6459daab1d357adafcbf7cb008f5b8969e5