From 3cbea183278d29ee4a3d45d09cca7ebc35de586a Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 1 Jul 2023 03:25:09 +0300 Subject: [PATCH] make emoji search work on original usernames --- files/assets/js/emoji_modal.js | 21 +++++++++++++-------- files/classes/emoji.py | 8 ++++++-- files/routes/static.py | 5 ++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/files/assets/js/emoji_modal.js b/files/assets/js/emoji_modal.js index aa1330296..72b79d4fc 100644 --- a/files/assets/js/emoji_modal.js +++ b/files/assets/js/emoji_modal.js @@ -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; diff --git a/files/classes/emoji.py b/files/classes/emoji.py index 648671b46..073be9ee4 100644 --- a/files/classes/emoji.py +++ b/files/classes/emoji.py @@ -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 diff --git a/files/routes/static.py b/files/routes/static.py index edceab422..ceb906dbc 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -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