diff --git a/lib/model/emoji.dart b/lib/model/emoji.dart index 160f2ba3e5..2c2492bfbf 100644 --- a/lib/model/emoji.dart +++ b/lib/model/emoji.dart @@ -264,9 +264,9 @@ class EmojiStoreImpl with EmojiStore { Map>? _serverEmojiData; static final _popularEmojiCodes = (() { - assert(zulipPopularEmojis.every((c) => + assert(EmojiStore.popularEmojiCandidates.every((c) => c.emojiType == ReactionType.unicodeEmoji)); - return Set.of(zulipPopularEmojis.map((c) => c.emojiCode)); + return Set.of(EmojiStore.popularEmojiCandidates.map((c) => c.emojiCode)); })(); static bool _isPopularEmoji(EmojiCandidate candidate) { @@ -316,7 +316,7 @@ class EmojiStoreImpl with EmojiStore { // Include the "popular" emoji, in their canonical order // relative to each other. - results.addAll(zulipPopularEmojis); + results.addAll(EmojiStore.popularEmojiCandidates); final namesOverridden = { for (final emoji in realmEmoji.values) emoji.name, diff --git a/lib/widgets/action_sheet.dart b/lib/widgets/action_sheet.dart index a0634a5d9a..ffca980345 100644 --- a/lib/widgets/action_sheet.dart +++ b/lib/widgets/action_sheet.dart @@ -45,7 +45,7 @@ void showMessageActionSheet({required BuildContext context, required Message mes final showMarkAsUnreadButton = markAsUnreadSupported && isMessageRead; final optionButtons = [ - ReactionButtons(message: message, pageContext: context, popularEmojis: zulipPopularEmojis), + ReactionButtons(message: message, pageContext: context, popularEmojis: EmojiStore.popularEmojiCandidates.toList()), StarButton(message: message, pageContext: context), if (isComposeBoxOffered) QuoteAndReplyButton(message: message, pageContext: context), diff --git a/test/model/emoji_test.dart b/test/model/emoji_test.dart index 486d6b90dc..c60e00b237 100644 --- a/test/model/emoji_test.dart +++ b/test/model/emoji_test.dart @@ -78,6 +78,8 @@ void main() { }); }); + final popularCandidates = EmojiStore.popularEmojiCandidates; + Condition isUnicodeCandidate(String? emojiCode, List? names) { return (it_) { final it = it_.isA(); @@ -108,7 +110,7 @@ void main() { ..aliases.isEmpty(); } - List> arePopularCandidates = zulipPopularEmojis.map( + List> arePopularCandidates = popularCandidates.map( (c) => isUnicodeCandidate(c.emojiCode, null)).toList(); group('allEmojiCandidates', () { @@ -139,10 +141,10 @@ void main() { // and interspersed with other emoji. final store = prepare(unicodeEmoji: { '1f603': ['smiley'], - for (final candidate in zulipPopularEmojis.skip(3)) + for (final candidate in popularCandidates.skip(3)) candidate.emojiCode: [candidate.emojiName, ...candidate.aliases], '1f34a': ['orange', 'tangerine', 'mandarin'], - for (final candidate in zulipPopularEmojis.take(3)) + for (final candidate in popularCandidates.take(3)) candidate.emojiCode: [candidate.emojiName, ...candidate.aliases], '1f516': ['bookmark'], }); @@ -150,7 +152,7 @@ void main() { // and are in their canonical order, even though the other Unicode emoji // are in the same order they were given in. check(store.allEmojiCandidates()).deepEquals([ - for (final candidate in zulipPopularEmojis) + for (final candidate in popularCandidates) isUnicodeCandidate(candidate.emojiCode, [candidate.emojiName, ...candidate.aliases]), isUnicodeCandidate('1f603', ['smiley']), @@ -264,7 +266,7 @@ void main() { isZulipCandidate()); } - List> arePopularResults = zulipPopularEmojis.map( + List> arePopularResults = popularCandidates.map( (c) => isUnicodeResult(emojiCode: c.emojiCode)).toList(); PerAccountStore prepare({ diff --git a/test/widgets/action_sheet_test.dart b/test/widgets/action_sheet_test.dart index 79935ef7a0..31050fd9d8 100644 --- a/test/widgets/action_sheet_test.dart +++ b/test/widgets/action_sheet_test.dart @@ -109,6 +109,8 @@ void main() { group('ReactionButtons', () { group('popular emoji reactions;', () { + final popularCandidates = EmojiStore.popularEmojiCandidates; + testWidgets('ensure all are shown', (tester) async { final message = eg.streamMessage(); await setupToMessageActionSheet(tester, message: message, narrow: TopicNarrow.ofMessage(message)); @@ -117,7 +119,7 @@ void main() { final buttons = tester.widgetList(find.descendant( of: find.byType(ReactionButtons) , matching: find.byType(IconButton))); - check(buttons).length.equals(zulipPopularEmojis.length); + check(buttons).length.equals(popularCandidates.length); // Ensure all are unicode emoji buttons. final emojis = tester.widgetList(find.descendant( @@ -125,7 +127,7 @@ void main() { of: find.byType(ReactionButtons) , matching: find.byType(IconButton)), matching: find.byType(UnicodeEmojiWidget))); - check(emojis).deepEquals(zulipPopularEmojis.map>((emoji) { + check(emojis).deepEquals(popularCandidates.map>((emoji) { final emojiDisplay = emoji.emojiDisplay as UnicodeEmojiDisplay; return (it) => it.isA() ..emojiDisplay.which((it) => it @@ -134,7 +136,7 @@ void main() { })); }); - for (final emoji in zulipPopularEmojis) { + for (final emoji in popularCandidates) { final emojiDisplay = emoji.emojiDisplay as UnicodeEmojiDisplay; Future tapButton(WidgetTester tester) async {