fix: fix wrong emoji being posted for flags and the emojis not elliding

This commit is contained in:
Jonathan Rainville 2020-07-06 11:03:41 -04:00 committed by Iuri Matias
parent 6e8c371063
commit 4c2e50ae47
4 changed files with 17 additions and 6 deletions

View File

@ -40,10 +40,9 @@ Item {
property bool hovered: false
id: emojiIconContainer
visible: txtData.length == 0
width: emojiIcon.width + chatButtonsContainer.iconPadding * 2
height: emojiIcon.height + chatButtonsContainer.iconPadding * 2
anchors.right: stickerIconContainer.left
anchors.right: txtData.length == 0 ? stickerIconContainer.left : chatSendBtn.left
anchors.rightMargin: Style.current.padding - chatButtonsContainer.iconPadding * 2
anchors.verticalCenter: parent.verticalCenter
radius: Style.current.radius

View File

@ -33,7 +33,6 @@ Rectangle {
anchors.fill: parent
ScrollView {
anchors.fill: parent
Layout.fillWidth: true
Layout.fillHeight: true
@ -66,7 +65,7 @@ Rectangle {
Layout.minimumWidth: 30 + Style.current.padding
Layout.maximumWidth: 200
addToChat: function (text) {
txtData.append(text)
txtData.insert(txtData.length, text)
}
}
}

View File

@ -74,6 +74,7 @@ Rectangle {
StyledText {
id: lastChatMessage
text: lastMessage ? Emoji.parse(lastMessage, "26x26").replace(/\n|\r/g, ' ') : qsTr("No messages")
clip: true // This is needed because emojis don't ellide correctly
anchors.right: contactNumberChatsCircle.left
anchors.rightMargin: Style.current.smallPadding
elide: Text.ElideRight

View File

@ -81,8 +81,20 @@ Popup {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: {
const encodedIcon = Emoji.fromCodePoint(filename.replace(".svg", ""))
popup.addToChat(encodedIcon)
const extenstionIndex = filename.lastIndexOf('.');
let iconCodePoint = filename
if (extenstionIndex > -1) {
iconCodePoint = iconCodePoint.substring(0, extenstionIndex)
}
// Split the filename to get all the parts and then encode them from hex to utf8
const splitCodePoint = iconCodePoint.split('-')
let codePointParts = []
splitCodePoint.forEach(function (codePoint) {
codePointParts.push(`0x${codePoint}`)
})
const encodedIcon = String.fromCodePoint(...codePointParts);
popup.addToChat(encodedIcon + ' ') // Adding a space because otherwise, some emojis would fuse since it's just an emoji is just a string
popup.close()
}
}