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,7 +253,8 @@ function openEmojiModal(t, inputTargetIDName)
switch (emojiEngineState) { switch (emojiEngineState) {
case "inactive": case "inactive":
emojiEngineState = "loading" emojiEngineState = "loading"
makeEmojisSearchDictionary(); if (searchDictionaryState == "inactive")
makeEmojisSearchDictionary();
return fetchEmojis(); return fetchEmojis();
case "loading": case "loading":
// this works because once the fetch completes, the first keystroke callback will fire and use the current value // this works because once the fetch completes, the first keystroke callback will fire and use the current value

View File

@ -1,4 +1,5 @@
// tags dictionary. KEEP IT SORT let searchDictionaryState = "inactive";
class EmoijsDictNode class EmoijsDictNode
{ {
constructor(tag, name) { constructor(tag, name) {
@ -6,6 +7,7 @@ class EmoijsDictNode
this.emojiNames = [name]; this.emojiNames = [name];
} }
} }
const emojisSearchDictionary = { const emojisSearchDictionary = {
dict: [], dict: [],
@ -85,6 +87,6 @@ function makeEmojisSearchDictionary() {
emojisSearchDictionary.updateTag(emoji.tags[i], emoji.name); 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 emoji_typing_state = false;
let globalEmojis; let globalEmojis;
@ -211,9 +210,9 @@ function insertGhostDivs(element) {
function openSpeedModal() function openSpeedModal()
{ {
switch (emojiSpeedEngineState) { switch (searchDictionaryState) {
case "inactive": case "inactive":
emojiSpeedEngineState = "loading" searchDictionaryState = "loading"
return makeEmojisSearchDictionary(); return makeEmojisSearchDictionary();
case "loading": case "loading":
// this works because once the fetch completes, the first keystroke callback will fire and use the current value // this works because once the fetch completes, the first keystroke callback will fire and use the current value