make emoji search work on original usernames

pull/163/head
Aevann 2023-07-01 03:25:09 +03:00
parent 80191ea98c
commit 3cbea18327
3 changed files with 23 additions and 11 deletions

View File

@ -174,11 +174,16 @@ function fetchEmojis() {
const emoji = emojis[i];
emojisSearchDictionary.updateTag(emoji.name, emoji.name);
if(emoji.author !== undefined && emoji.author !== null)
{
emojisSearchDictionary.updateTag(`@${emoji.author.toLowerCase()}`, emoji.name);
}
if(emoji.author_username !== undefined && emoji.author_username !== null)
emojisSearchDictionary.updateTag(`@${emoji.author_username.toLowerCase()}`, emoji.name);
if(emoji.author_original_username !== undefined && emoji.author_original_username !== null)
emojisSearchDictionary.updateTag(`@${emoji.author_original_username.toLowerCase()}`, emoji.name);
if(emoji.author_prelock_username !== undefined && emoji.author_prelock_username !== null)
emojisSearchDictionary.updateTag(`@${emoji.author_prelock_username.toLowerCase()}`, emoji.name);
if(emoji.tags instanceof Array)
for(let i = 0; i < emoji.tags.length; i++)
emojisSearchDictionary.updateTag(emoji.tags[i], emoji.name);
@ -187,8 +192,8 @@ function fetchEmojis() {
const emojiDOM = document.importNode(emojiButtonTemplateDOM.content, true).children[0];
emojiDOM.title = emoji.name
if(emoji.author !== undefined && emoji.author !== null)
emojiDOM.title += "\nauthor\t" + emoji.author
if(emoji.author_username !== undefined && emoji.author_username !== null)
emojiDOM.title += "\nauthor\t" + emoji.author_username
if(emoji.count !== undefined)
emojiDOM.title += "\nused\t" + emoji.count;
emojiDOM.dataset.className = emoji.kind;
@ -400,8 +405,8 @@ function populate_speed_emoji_modal(results, textbox)
emoji_option_text.title = name;
if(emoji.author !== undefined && emoji.author !== null)
emoji_option_text.title += "\nauthor\t" + emoji.author
if(emoji.author_username !== undefined && emoji.author_username !== null)
emoji_option_text.title += "\nauthor\t" + emoji.author_username
if(emoji.count !== undefined)
emoji_option_text.title += "\nused\t" + emoji.count;

View File

@ -36,6 +36,10 @@ class Emoji(Base):
"created_utc": self.created_utc,
"kind": self.kind,
}
if "author" in self.__dict__ and self.author:
data["author"] = self.author
if "author_username" in self.__dict__ and self.author_username:
data["author_username"] = self.author_username
if "author_original_username" in self.__dict__ and self.author_original_username:
data["author_original_username"] = self.author_original_username
if "author_prelock_username" in self.__dict__ and self.author_prelock_username:
data["author_prelock_username"] = self.author_prelock_username
return data

View File

@ -80,7 +80,10 @@ def get_emojis():
collected = []
for emoji, author in emojis:
emoji.author = author.username if FEATURES['ASSET_SUBMISSIONS'] else None
if FEATURES['ASSET_SUBMISSIONS']:
emoji.author_username = author.username
emoji.author_original_username = author.original_username
emoji.author_prelock_username = author.prelock_username
collected.append(emoji.json())
return collected