dont remake search dictionary if its alrdy made

master
Aevann 2023-10-27 14:51:36 +03:00
parent 0136b5b975
commit 9b03eb83b5
3 changed files with 8 additions and 6 deletions

View File

@ -253,6 +253,7 @@ function openEmojiModal(t, inputTargetIDName)
switch (emojiEngineState) {
case "inactive":
emojiEngineState = "loading"
if (searchDictionaryState == "inactive")
makeEmojisSearchDictionary();
return fetchEmojis();
case "loading":

View File

@ -1,4 +1,5 @@
// tags dictionary. KEEP IT SORT
let searchDictionaryState = "inactive";
class EmoijsDictNode
{
constructor(tag, name) {
@ -6,6 +7,7 @@ class EmoijsDictNode
this.emojiNames = [name];
}
}
const emojisSearchDictionary = {
dict: [],
@ -85,6 +87,6 @@ function makeEmojisSearchDictionary() {
emojisSearchDictionary.updateTag(emoji.tags[i], emoji.name);
}
emojiSpeedEngineState = "ready";
searchDictionaryState = "ready";
})
}

View File

@ -1,4 +1,3 @@
let emojiSpeedEngineState = "inactive";
let emoji_typing_state = false;
let globalEmojis;
@ -211,9 +210,9 @@ function insertGhostDivs(element) {
function openSpeedModal()
{
switch (emojiSpeedEngineState) {
switch (searchDictionaryState) {
case "inactive":
emojiSpeedEngineState = "loading"
searchDictionaryState = "loading"
return makeEmojisSearchDictionary();
case "loading":
// this works because once the fetch completes, the first keystroke callback will fire and use the current value