@@ -109,6 +109,19 @@ mixin EmojiStore {
109
109
required String emojiName,
110
110
});
111
111
112
+ /// Zulip's list of "popular" emoji, to be given precedence in
113
+ /// offering to users.
114
+ ///
115
+ /// See description in the web code:
116
+ /// https://github.com/zulip/zulip/blob/83a121c7e/web/shared/src/typeahead.ts#L3-L21
117
+ // Someday this list may start varying rather than being hard-coded,
118
+ // and then this will become a non-static member on EmojiStore.
119
+ // For now, though, the fact it's constant is convenient when writing
120
+ // tests of the logic that uses this data; so we guarantee it in the API.
121
+ static Iterable <EmojiCandidate > get popularEmojiCandidates {
122
+ return EmojiStoreImpl ._popularCandidates;
123
+ }
124
+
112
125
Iterable <EmojiCandidate > allEmojiCandidates ();
113
126
114
127
// TODO cut debugServerEmojiData once we can query for lists of emoji;
@@ -207,7 +220,29 @@ class EmojiStoreImpl with EmojiStore {
207
220
/// retrieving the data.
208
221
Map <String , List <String >>? _serverEmojiData;
209
222
210
- List <EmojiCandidate >? _allEmojiCandidates;
223
+ static final _popularCandidates = _generatePopularCandidates ();
224
+
225
+ static List <EmojiCandidate > _generatePopularCandidates () {
226
+ EmojiCandidate candidate (String emojiCode, String emojiUnicode,
227
+ List <String > names) {
228
+ final emojiName = names.removeAt (0 );
229
+ assert (emojiUnicode == tryParseEmojiCodeToUnicode (emojiCode));
230
+ return EmojiCandidate (emojiType: ReactionType .unicodeEmoji,
231
+ emojiCode: emojiCode, emojiName: emojiName, aliases: names,
232
+ emojiDisplay: UnicodeEmojiDisplay (
233
+ emojiName: emojiName, emojiUnicode: emojiUnicode));
234
+ }
235
+ return [
236
+ // This list should match web:
237
+ // https://github.com/zulip/zulip/blob/83a121c7e/web/shared/src/typeahead.ts#L22-L29
238
+ candidate ('1f44d' , '👍' , ['+1' , 'thumbs_up' , 'like' ]),
239
+ candidate ('1f389' , '🎉' , ['tada' ]),
240
+ candidate ('1f642' , '🙂' , ['smile' ]),
241
+ candidate ( '2764' , '❤' , ['heart' , 'love' , 'love_you' ]),
242
+ candidate ('1f6e0' , '🛠' , ['working_on_it' , 'hammer_and_wrench' , 'tools' ]),
243
+ candidate ('1f419' , '🐙' , ['octopus' ]),
244
+ ];
245
+ }
211
246
212
247
EmojiCandidate _emojiCandidateFor ({
213
248
required ReactionType emojiType,
@@ -306,6 +341,8 @@ class EmojiStoreImpl with EmojiStore {
306
341
return results;
307
342
}
308
343
344
+ List <EmojiCandidate >? _allEmojiCandidates;
345
+
309
346
@override
310
347
Iterable <EmojiCandidate > allEmojiCandidates () {
311
348
return _allEmojiCandidates ?? = _generateAllCandidates ();
0 commit comments