Skip to content
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

Introduce EmojiStore for some existing emoji logic #967

Merged
merged 8 commits into from
Sep 30, 2024

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Sep 27, 2024

This is a refactoring that prepares us for #669, as well as for #388 and #670.

@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Sep 27, 2024
Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM, small comments below.

Comment on lines 375 to 377
final resolvedUrl =
doNotAnimate ? (emojiDisplay.resolvedStillUrl ?? emojiDisplay.resolvedUrl)
: emojiDisplay.resolvedUrl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final resolvedUrl =
doNotAnimate ? (emojiDisplay.resolvedStillUrl ?? emojiDisplay.resolvedUrl)
: emojiDisplay.resolvedUrl;
final resolvedUrl =
doNotAnimate
? (emojiDisplay.resolvedStillUrl ?? emojiDisplay.resolvedUrl)
: emojiDisplay.resolvedUrl;

or

Suggested change
final resolvedUrl =
doNotAnimate ? (emojiDisplay.resolvedStillUrl ?? emojiDisplay.resolvedUrl)
: emojiDisplay.resolvedUrl;
final resolvedUrl = doNotAnimate
? (emojiDisplay.resolvedStillUrl ?? emojiDisplay.resolvedUrl)
: emojiDisplay.resolvedUrl;

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll do the second of those.

Comment on lines 46 to 49
// Code matches against code, not against name.
checkDisplay(emojiCode: '123', emojiName: '100').isA<ImageEmojiDisplay>()
..resolvedUrl.equals(eg.realmUrl.resolve('/emoji/123.png'))
..resolvedStillUrl.isNull();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow the comment. "Code" (the first word) means "emoji code", right, or does it mean the app code? What bug is this test written against?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it means "emoji code" as opposed to "emoji name". I'll make the comment less elliptical:

      // Emoji code matches against emoji code, not against emoji name.

The hypothetical bug here isn't a super likely one (because if we had it, then probably most uses would just fail and so we'd notice promptly in manual testing): it's that because both emoji codes and emoji names are just strings, we could take the given emoji name and look it up someplace where the keys are actually supposed to be emoji codes.

@chrisbobbe
Copy link
Collaborator

(CI should be resolved by rebasing past #968.)

This gives us a good home to add the server's list of Unicode emoji.
This describes the semantics of part of Zulip's API.
This will apply in other places we show an emoji, too,
such as the emoji picker.

What, you might ask, about the other place we already show emoji,
namely in message content?  We should probably apply this logic
there too, but we'll leave that for later.  Tracking it as issue zulip#966.
Some bits of data change in the one existing test that was using
these; but not any data that the test looks at.
Now that this logic has been pulled out to model code, we can
more easily write tests for it.
@gnprice gnprice merged commit 945066c into zulip:main Sep 30, 2024
1 check passed
@gnprice
Copy link
Member Author

gnprice commented Sep 30, 2024

Thanks for the review! Merged after those changes.

@gnprice gnprice deleted the pr-emoji branch September 30, 2024 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer review PR ready for review by Zulip maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants