-
-
Notifications
You must be signed in to change notification settings - Fork 278
Emoji data storage improvements and custom emoji support #710
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
Conversation
7e94ba0
to
e8cda96
Compare
@kaustubh-nair Based on comment in #zulip-terminal, ok to remove 'needs review', as other PRs are expected to come before this? |
@neiljp, this one of supposed to be merged before the others. |
e8cda96
to
3ed143e
Compare
1535d85
to
a6813f4
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.
@kaustubh-nair This is easy to read and review 👍 That makes it easier to give lots of feedback! This is mainly complex due to the types of emoji/reactions.
This PR has quite a bit of naming adjustment/improvement to allow for refactoring, which is good, but I wonder if we can improve those names - eg. emoji_data.py
only has unicode emoji data in it, and model.emoji_data
is only the active emoji.
One concern I have is that from rendering emoji (and/or reactions) we know that there is 'zulip extra' and 'custom' emoji (in addition to unicode emoji), yet you treat the server emoji as realm_emoji
- the server doesn't appear to distinguish in the data response, so perhaps that's fine. Should we test/handle these differently, though? These don't seem to be exposed differently in the API call response, and maybe it doesn't matter, but the reactions data does contain this difference, so how should we be handling this?
a84ddfa
to
fee1a98
Compare
6fe2920
to
af4e171
Compare
9684f4a
to
4008f26
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.
@kaustubh-nair Thanks for the update 👍
When I run the fetch/convert scripts on the branch, there seems to be a diff in unicode_emojis.py
.
I didn't see the manual addition of the :zulip:
emoji that needs to be added by each front-end yet?
Do you know if there are emoji events that should update the data we initially fetch?
For fetching the custom emoji, we could likely do this in parallel with the register and message-fetch at startup, but this seems fine as it is for now.
tests/model/test_model.py
Outdated
@@ -71,6 +75,7 @@ def test_init(self, model, initial_data, user_profile): | |||
assert model.unpinned_streams == [] | |||
self.classify_unread_counts.assert_called_once_with(model) | |||
assert model.unread_counts == [] | |||
assert model.emoji_data == unicode_emojis |
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.
What is emoji_data
? (you've changed to 'active_' below)
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.
Fixed. Missed this between commits
4008f26
to
166bb44
Compare
166bb44
to
1afde76
Compare
zulipterminal/model.py
Outdated
unicode_emoji_data = unicode_emojis.EMOJI_DATA | ||
for name, data in unicode_emoji_data.items(): | ||
data['type'] = 'unicode_emoji' | ||
typed_unicode_emoji_data = cast(NamedEmojiData, unicode_emoji_data) |
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.
This can't be done inline right?
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.
You've modified the original, so this seems reasonable 👍
df10ff7
to
4b2eb74
Compare
@neiljp Thanks for the review! Updated PR according to comments.
I can't see a diff on the unicode data? Did you run this recently?
This has been discussed on czo before, the server needs to share emoji data using an endpoint - there aren't any events for updating this yet. EDIT - Are you talking about custom emojis? |
@kaustubh-nair This looks good and should be mergeable after a rebase :) As per my comments on czo, I was referring to using events from the server to ensure that the custom emojis are kept up to date. The only aspect we might consider prior to merging would be handling failing responses from the The unicode data issue was fixed in one of your commits, from what I can tell :) |
The emoji data in the server file has been updated, this commit syncs the emoji data saved from that file.
4b2eb74
to
4896f2b
Compare
This makes the variable names more descriptive for when other emoji types, such as custom emojis, will have to be stored. * Rename emojis_fixture to unicode_emojis. * Rename emoji_names.py to unicode_emojis.py and rename the data stored in them to EMOJI_DATA. * Rename tools/convert-emoji-names to tools/convert-unicode-emoji-data and rename the I/O files used. * Rename tools/fetch-emoji-names to tools/fetch-unicode-emoji-data and rename output file created. * Rename test_emoji_names.py to test_emoji_data.py.
Save the data from unicode_emojis.py as a model attribute, instead of loading them directly from the file. This will make it easy, in the future, to use emoji data when it is fetched from different sources, for example - custom emojis that will be fetched using a server endpoint. Tests amended.
This commit stores the code and type of emojis in the emoji data stored in the model. This is important when other types of emojis are added. Emoji conversion script modified to store data in an OrderedDict.
* Fetch custom emojis from server which can be used by the user using typeahead. * Model tests amended. * New fixture and test added for custom emojis. Minor notes: * The emojis are being sorted twice here, once when unicode emojis are stored in the file using the script (which happens occasionally when it is manually updated) and again after custom emojis are fetched (which happens during every load). The first sorting seems pointless, at first glance, but it improves sorting time for the second one since sorted() uses Timsort that can perform better if subsequences of the data are already sorted. * A custom emoji will replace a unicode emoji if they have the same names.
This is a hard-coded emoji that replaces :zulip: emojis of other types. This emoji uses the zulip_extra_emoji type.
4896f2b
to
644618c
Compare
@kaustubh-nair Thanks for the update! I just fixed some recent minor conflicts and merged manually 🎉 As I indicated in the stream, as part of the synchronizing of the realm emoji, we should likely move to treating the initial fetch as being from the initial data from the register, which I've filed as #809. |
The main points of this PR are: