fix(statusChatInput): do not replace text with emojis on links

Closes #8478
This commit is contained in:
Alexandra Betouni 2023-02-14 17:13:03 +02:00 committed by Alexandra Betouni
parent ed9e782262
commit bb23131f0e

View File

@ -1175,8 +1175,7 @@ Rectangle {
ColumnLayout { ColumnLayout {
id: inputLayout id: inputLayout
width: parent.width
anchors.fill: parent
spacing: 4 spacing: 4
StatusChatInputReplyArea { StatusChatInputReplyArea {
@ -1207,17 +1206,15 @@ Rectangle {
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.minimumHeight: (messageInputField.contentHeight + messageInputField.topPadding + messageInputField.bottomPadding)
Layout.maximumHeight: 112
spacing: Style.current.radius spacing: Style.current.radius
StatusScrollView { StatusScrollView {
id: inputScrollView id: inputScrollView
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.leftMargin: 12 Layout.leftMargin: 12
Layout.rightMargin: 12 Layout.rightMargin: 12
Layout.maximumHeight: 112
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
padding: 0 padding: 0
@ -1285,13 +1282,14 @@ Rectangle {
onTextChanged: { onTextChanged: {
if (length <= control.messageLimit) { if (length <= control.messageLimit) {
var symbols = ":='xX><0O;*dB8-D#%\\"; var symbols = ":='xX><0O;*dB8-D#%\\";
if ((length > 1) && (symbols.indexOf(getText((cursorPosition - 2), (cursorPosition - 1))) !== -1) var symbolIdx = ((cursorPosition > 2) && (symbols.indexOf(getText((cursorPosition - 2), (cursorPosition - 1)))!==-1))
&& (!getText((cursorPosition - 7), cursorPosition).includes("http"))) { ? (cursorPosition -1) : (symbols.indexOf(getText(0, 1))!==-1) ? 2 : -1;
if ((getText(symbolIdx-2, (symbolIdx-1)) === " ") || (symbolIdx === 2)) {
const emojis = StatusQUtils.Emoji.emojiJSON.emoji_json.filter(function (emoji) { const emojis = StatusQUtils.Emoji.emojiJSON.emoji_json.filter(function (emoji) {
if (emoji.aliases_ascii.includes(getText((cursorPosition - 2), cursorPosition)) || if (emoji.aliases_ascii.includes(getText((symbolIdx-1), (symbolIdx+1))) ||
emoji.aliases_ascii.includes(getText((cursorPosition - 3), cursorPosition))) { emoji.aliases_ascii.includes(getText((symbolIdx-2), (symbolIdx+1)))) {
var has2Chars = emoji.aliases_ascii.includes(getText((cursorPosition - 2), cursorPosition)); var has2Chars = emoji.aliases_ascii.includes(getText((symbolIdx-4), (symbolIdx-2)));
replaceWithEmoji("", getText(cursorPosition - (has2Chars ? 2 : 3), cursorPosition), emoji.unicode); replaceWithEmoji("", getText((symbolIdx - (has2Chars ? 3 : 2)), symbolIdx), emoji.unicode);
} }
}) })
} }
@ -1460,7 +1458,7 @@ Rectangle {
color: "transparent" color: "transparent"
onClicked: { onClicked: {
control.stickersPopupOpened = true control.stickersPopupOpened = true
togglePopup(control.stickersPopup, stickersBtn) togglePopup(control.stickersPopup, stickersBtn)
} }
} }