mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-22 11:38:57 +00:00
fix: fix code review and fix deleting colon closes emoji popup
This commit is contained in:
parent
db6b87d813
commit
577dbba831
@ -111,7 +111,7 @@ Rectangle {
|
||||
var transform = true;
|
||||
if (words[i].charAt(0) === ':') {
|
||||
for (var j = 0; j < words[i].length; j++) {
|
||||
if (isSpace(words[i].charAt(j)) === true || Utils.isPunct(words[i].charAt(j)) === true) {
|
||||
if (Utils.isSpace(words[i].charAt(j)) === true || Utils.isPunct(words[i].charAt(j)) === true) {
|
||||
transform = false;
|
||||
}
|
||||
}
|
||||
@ -128,10 +128,10 @@ Rectangle {
|
||||
}
|
||||
|
||||
function replaceWithEmoji(message, shortname, codePoint) {
|
||||
const encodedCodePoint = Utils.getEmojiCodepoint(codePoint)
|
||||
const encodedCodePoint = Emoji.getEmojiCodepoint(codePoint)
|
||||
const newMessage = message.data
|
||||
.replace(shortname, encodedCodePoint)
|
||||
.replace(/ /g, " ");
|
||||
.replace(shortname, encodedCodePoint)
|
||||
.replace(/ /g, " ");
|
||||
txtData.remove(0, txtData.cursorPosition);
|
||||
insertInTextInput(0, Emoji.parse(newMessage, '26x26'));
|
||||
emojiSuggestions.close()
|
||||
@ -144,7 +144,7 @@ Rectangle {
|
||||
|
||||
// state machine to handle different forms of the emoji event state
|
||||
if (!emojiEvent && isColonPressed) {
|
||||
return (message.data.length <= 1 || isSpace(message.data.charAt(message.cursor - 1))) ? true : false;
|
||||
return (message.data.length <= 1 || Utils.isSpace(message.data.charAt(message.cursor - 1))) ? true : false;
|
||||
} else if (emojiEvent && isColonPressed) {
|
||||
const index = message.data.lastIndexOf(':', message.cursor - 2);
|
||||
if (index >= 0 && message.cursor > 0) {
|
||||
@ -170,8 +170,8 @@ Rectangle {
|
||||
|
||||
emojiSuggestions.openPopup(emojis, emojiPart)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
} else if (emojiEvent && !isKeyValid(event.key) && !isColonPressed) {
|
||||
return false;
|
||||
}
|
||||
@ -237,7 +237,7 @@ Rectangle {
|
||||
function validSubstr(substr) {
|
||||
for(var i = 0; i < substr.length; i++) {
|
||||
var c = substr.charAt(i);
|
||||
if (c !== '_' && (isSpace(c) === true || Utils.isPunct(c) === true)) {
|
||||
if (c !== '_' && (Utils.isSpace(c) === true || Utils.isPunct(c) === true)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -254,12 +254,6 @@ Rectangle {
|
||||
return true;
|
||||
}
|
||||
|
||||
function isSpace(c) {
|
||||
if (/( |\t|\n|\r)/.test(c))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: imageDialog
|
||||
//% "Please choose an image"
|
||||
|
@ -40,7 +40,7 @@ Popup {
|
||||
iconCodePoint = iconCodePoint.substring(0, extenstionIndex)
|
||||
}
|
||||
|
||||
const encodedIcon = Utils.getEmojiCodepoint(iconCodePoint)
|
||||
const encodedIcon = Emoji.getEmojiCodepoint(iconCodePoint)
|
||||
|
||||
// Add at the start of the list
|
||||
let recentEmojis = appSettings.recentEmojis
|
||||
|
@ -39,4 +39,14 @@ QtObject {
|
||||
return _emoji.unicode;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getEmojiCodepoint(iconCodePoint) {
|
||||
// Split the codepoint 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}`)
|
||||
})
|
||||
return String.fromCodePoint(...codePointParts);
|
||||
}
|
||||
}
|
||||
|
@ -140,14 +140,8 @@ QtObject {
|
||||
}
|
||||
}
|
||||
|
||||
function getEmojiCodepoint(iconCodePoint) {
|
||||
// Split the codepoint 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}`)
|
||||
})
|
||||
return String.fromCodePoint(...codePointParts);
|
||||
function isSpace(c) {
|
||||
return (/( |\t|\n|\r)/.test(c))
|
||||
}
|
||||
|
||||
function isPunct(c) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user