-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate emoji storage to group aliases together for each canonical name. #1084
Conversation
2fdf218
to
46a7cf3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zee-bit Thanks for working on this. This looks good overall. 👍 Though, as there has been a discussion on CZO, generating the new file midway or separately in a commit would bring discrepancies in model.py
.
d7339ae
to
1a32875
Compare
94c5569
to
23a95d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zee-bit You've got the correct principle here. To ease the migration and avoid the mid-commit regression (which should be breaking tests?), a possible refactoring would be to first adjust the emoji data generation function to return an additional set of data ie. the pre-prepared emoji names, adapting the autocomplete to use it. You can then regenerate the emoji file and the emoji manipulation internal to the model at the same time in the next commit.
zulipterminal/model.py
Outdated
self.active_emoji_data = self.generate_all_emoji_data( | ||
self.initial_data["realm_emoji"] | ||
) | ||
self.all_emoji_names = self.generate_all_emoji_names() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We update emoji when we get a realm emoji change event, so we at least want to call both in each case, or have one method that returns a tuple and updates both at the same time.
This commit adds a new instance variable in model that stores the list of all emoji names generated during model initialization by the generate_emoji_data function. The generate_emoji_data function now return a tuple of all active emoji data and all emoji names sorted. This also migrates the autocomplete emoji function to use the list of all_emoji_names returned from this, instead of generating it multiple times during runtime whenever autocomplete emoji is called. Tests amended.
This commit updates the convert-unicode-emoji-data script to store all the unicode emoji codepoints in their extended format as received from the server. This script will map each emoji_name (aka canonical_name) to its data containing the emoji_code and aliases that share the same emoji_code. We sort this dictionary in ascending order of key (emoji_name) and store it as an OrderedDict to maintain the order of sorting. We also turn off black formatting by wrapping the file with fmt: off/on to disable black from formatting the dictionaries afterwards - since that is a generated file, it should not be modified.
E501 ignores max-line-length property - this is already defined by black. We add this error code in flake8's ignore list in setup.cfg file.
This commit generates the EMOJI_DATA from tools/convert-unicode-emoji-data in the new format that maps each emoji_name to its corresponding emoji's code, and aliases that share the same emoji_code, stored in an OrderedDict. The EMOJI_DATA is sorted in ascending order of emoji_name and this ordering is maintained via OrderedDict. The generated EMOJI_DATA is stored in unicode_emojis.py file. This also updates the helper function in model that generates all emoji data to follow and adapt to this new format of storing emoji's and updates the EmojiData type to indicate each emoji now includes an aliases field. This also migrates the emoji fixtures in conftest i.e. realm_emoji_data, unicode_emojis and zulip_emoji to the new format of storing emoji_data. Tests amended.
23a95d5
to
0aecbeb
Compare
@zee-bit This flows much cleaner with no mid-PR regressions - great! Merging this now 🎉 |
Hello @zulip/server-refactoring members, this pull request was labeled with the "area: refactoring" label, so you may want to check it out! |
What does this PR do?
Migrates our emoji storage structure in
unicode_emojis.py
to a new structure wherefor each
canonical_name
we keep its aliases grouped together, instead of consideringthem as separate emojis.
Tested?
Notes & Questions
I need to test the reactions PR on top of this to determine the authenticity of this migration.
Interactions