perf(chatScroll): Improve performance of the commonly used js libraries

Adding .pragma library to the js libraries because the entry point on these libraries were called multiple times. There is no need to share the qml context with these libraries.
Use find() instead of forEach() on emoji array to find an item
This commit is contained in:
Alex Jbanca 2023-01-10 13:18:53 +02:00 committed by Alex Jbanca
parent 7adcbebb53
commit 15fe97c90c
3 changed files with 6 additions and 4 deletions

View File

@ -82,10 +82,9 @@ QtObject {
return value.match(/<img class=\"emoji\" draggable=\"false\" alt=\"(.+?)\" src=\".+?\/StatusQ\/src\/assets\/twemoji\/.+?" width=\"[0-9]*\" height=\"[0-9]*\" style=\"(.+?)\" ?\/>/g, "$1");
}
function getEmojiUnicode(shortname) {
var _emoji;
EmojiJSON.emoji_json.forEach(function(emoji) {
if (emoji.shortname === shortname)
_emoji = emoji;
const _emoji = EmojiJSON.emoji_json.find(function(emoji) {
return (emoji.shortname === shortname)
})
if (_emoji !== undefined)

View File

@ -1,3 +1,5 @@
.pragma library
var emojiCategories = [
"time",
"smileys-and-people",

View File

@ -4,6 +4,7 @@
* Most this code was copied from https://github.com/leizongmin/js-xss and slightly modifed
* to work with JavaScript resource loading in QML.
*/
.pragma library
var defaultCSSFilter = new FilterCSS();