-
Notifications
You must be signed in to change notification settings - Fork 306
emoji: Generate popular candidates using names from server data #1506
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
Open
chrisbobbe
wants to merge
14
commits into
zulip:main
Choose a base branch
from
chrisbobbe:pr-fix-smile-emoji-button
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+283
−156
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bbbaa53
emoji [nfc]: Move list of popular emoji codes to its own static field
chrisbobbe 5973fec
emoji [nfc]: Read _popularCandidates only through public getter
chrisbobbe ecb4f7d
emoji [nfc]: Make popularEmojiCandidates non-static
chrisbobbe a60ff3f
emoji [nfc]: Make popularEmojiCandidates a method, not getter
chrisbobbe e8728f5
emoji [nfc]: Move popularEmojiCandidates implementation down out of m…
chrisbobbe 13292a9
emoji test: Change one autocomplete test to use a non-popular emoji
chrisbobbe 774542e
test: Add eg.serverEmojiDataPopular for tests that would break withou…
chrisbobbe f66c812
emoji [nfc]: Make a helper's helper not mutate lists of emoji names
chrisbobbe 42f3d21
emoji_reaction test: Do a store.setServerEmojiData earlier
chrisbobbe b8abc6b
emoji test [nfc]: Make a nested `prepare` more like another (1/2)
chrisbobbe d8d9e58
emoji test [nfc]: Make a nested `prepare` more like another (2/2)
chrisbobbe 3d341b8
emoji test [nfc]: Pull out `prepare` function for reuse
chrisbobbe 1a40f27
emoji: Generate popular candidates using names from server data
chrisbobbe 076b689
test: Change '1f642': 'smile' emoji to 'slight_smile' where it appears
chrisbobbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -554,6 +554,8 @@ void showMessageActionSheet({required BuildContext context, required Message mes | |
final pageContext = PageRoot.contextOf(context); | ||
final store = PerAccountStoreWidget.of(pageContext); | ||
|
||
final popularEmojiLoaded = store.popularEmojiCandidates().isNotEmpty; | ||
|
||
// The UI that's conditioned on this won't live-update during this appearance | ||
// of the action sheet (we avoid calling composeBoxControllerOf in a build | ||
// method; see its doc). | ||
|
@@ -567,7 +569,8 @@ void showMessageActionSheet({required BuildContext context, required Message mes | |
final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead; | ||
|
||
final optionButtons = [ | ||
ReactionButtons(message: message, pageContext: pageContext), | ||
if (popularEmojiLoaded) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can have a test checking when this should not be offered, like we do with quote-and-reply button. |
||
ReactionButtons(message: message, pageContext: pageContext), | ||
StarButton(message: message, pageContext: pageContext), | ||
if (isComposeBoxOffered) | ||
QuoteAndReplyButton(message: message, pageContext: pageContext), | ||
|
@@ -665,11 +668,18 @@ class ReactionButtons extends StatelessWidget { | |
|
||
@override | ||
Widget build(BuildContext context) { | ||
assert(EmojiStore.popularEmojiCandidates.every( | ||
final store = PerAccountStoreWidget.of(pageContext); | ||
final popularEmojiCandidates = store.popularEmojiCandidates(); | ||
assert(popularEmojiCandidates.every( | ||
(emoji) => emoji.emojiType == ReactionType.unicodeEmoji)); | ||
// (if this is empty, the widget isn't built in the first place) | ||
assert(popularEmojiCandidates.isNotEmpty); | ||
// UI not designed to handle more than 6 popular emoji. | ||
// (We might have fewer if ServerEmojiData is lacking expected data, | ||
// but that looks fine in manual testing, even when there's just one.) | ||
assert(popularEmojiCandidates.length <= 6); | ||
|
||
final zulipLocalizations = ZulipLocalizations.of(context); | ||
final store = PerAccountStoreWidget.of(pageContext); | ||
final designVariables = DesignVariables.of(context); | ||
|
||
bool hasSelfVote(EmojiCandidate emoji) { | ||
|
@@ -685,7 +695,7 @@ class ReactionButtons extends StatelessWidget { | |
color: designVariables.contextMenuItemBg.withFadedAlpha(0.12)), | ||
child: Row(children: [ | ||
Flexible(child: Row(spacing: 1, children: List.unmodifiable( | ||
EmojiStore.popularEmojiCandidates.mapIndexed((index, emoji) => | ||
popularEmojiCandidates.mapIndexed((index, emoji) => | ||
_buildButton( | ||
context: context, | ||
emoji: emoji, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
From what I understand,
_generateAllCandidates
gets called (and then_generatePopularCandidates
) during the first access tostore.allEmojiCandidates
, and the data stays cached afterwards.The popular emojis among them, created from
_generatePopularCandidates
, rely on what_serverEmojiData
is at the time we access the emoji candidates. Is it possible for the user to access the picker a bit too early, such that_serverEmojiData
is still null when we create the cache? If so, do we have a way to correct that?Oh, then I saw the lines in
setServerEmojiData
that sets the cached candidates back tonull
, so that should be fine. I feel that a test for the part where we invalidate the popular emoji candidates when we do get the data should help,