-
Notifications
You must be signed in to change notification settings - Fork 309
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2fae1de
emoji [nfc]: Move list of popular emoji codes to its own static field
chrisbobbe fc5bd89
emoji [nfc]: Read _popularCandidates only through public getter
chrisbobbe 23902ad
emoji [nfc]: Make popularEmojiCandidates non-static
chrisbobbe 0522158
emoji [nfc]: Make popularEmojiCandidates a method, not getter
chrisbobbe 8c2dfe7
emoji [nfc]: Move popularEmojiCandidates implementation down out of m…
chrisbobbe eee7bcd
emoji test: Change one autocomplete test to use a non-popular emoji
chrisbobbe f1b65bb
test: Add eg.serverEmojiDataPopular for tests that would break withou…
chrisbobbe 0c44bcb
emoji [nfc]: Make a helper's helper not mutate lists of emoji names
chrisbobbe bf60af5
emoji_reaction test: Do a store.setServerEmojiData earlier
chrisbobbe 140c4cb
emoji test [nfc]: Make a nested `prepare` more like another (1/2)
chrisbobbe 39d57e2
emoji test [nfc]: Make a nested `prepare` more like another (2/2)
chrisbobbe e55cebd
emoji test [nfc]: Pull out `prepare` function for reuse
chrisbobbe 34a562a
emoji: Generate popular candidates using names from server data
chrisbobbe df51b3f
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 |
---|---|---|
|
@@ -555,6 +555,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). | ||
|
@@ -568,7 +570,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), | ||
|
@@ -698,11 +701,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) { | ||
|
@@ -718,7 +728,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,