@@ -113,6 +113,19 @@ mixin EmojiStore {
113
113
required String emojiName,
114
114
});
115
115
116
+ /// Zulip's list of "popular" emoji, to be given precedence in
117
+ /// offering to users.
118
+ ///
119
+ /// See description in the web code:
120
+ /// https://github.com/zulip/zulip/blob/83a121c7e/web/shared/src/typeahead.ts#L3-L21
121
+ // Someday this list may start varying rather than being hard-coded,
122
+ // and then this will become a non-static member on EmojiStore.
123
+ // For now, though, the fact it's constant is convenient when writing
124
+ // tests of the logic that uses this data; so we guarantee it in the API.
125
+ static Iterable <EmojiCandidate > get popularEmojiCandidates {
126
+ return EmojiStoreImpl ._popularCandidates;
127
+ }
128
+
116
129
Iterable <EmojiCandidate > allEmojiCandidates ();
117
130
118
131
// TODO cut debugServerEmojiData once we can query for lists of emoji;
@@ -200,7 +213,29 @@ class EmojiStoreImpl with EmojiStore {
200
213
/// retrieving the data.
201
214
Map <String , List <String >>? _serverEmojiData;
202
215
203
- List <EmojiCandidate >? _allEmojiCandidates;
216
+ static final _popularCandidates = _generatePopularCandidates ();
217
+
218
+ static List <EmojiCandidate > _generatePopularCandidates () {
219
+ EmojiCandidate candidate (String emojiCode, String emojiUnicode,
220
+ List <String > names) {
221
+ final emojiName = names.removeAt (0 );
222
+ assert (emojiUnicode == tryParseEmojiCodeToUnicode (emojiCode));
223
+ return EmojiCandidate (emojiType: ReactionType .unicodeEmoji,
224
+ emojiCode: emojiCode, emojiName: emojiName, aliases: names,
225
+ emojiDisplay: UnicodeEmojiDisplay (
226
+ emojiName: emojiName, emojiUnicode: emojiUnicode));
227
+ }
228
+ return [
229
+ // This list should match web:
230
+ // https://github.com/zulip/zulip/blob/83a121c7e/web/shared/src/typeahead.ts#L22-L29
231
+ candidate ('1f44d' , '👍' , ['+1' , 'thumbs_up' , 'like' ]),
232
+ candidate ('1f389' , '🎉' , ['tada' ]),
233
+ candidate ('1f642' , '🙂' , ['smile' ]),
234
+ candidate ( '2764' , '❤' , ['heart' , 'love' , 'love_you' ]),
235
+ candidate ('1f6e0' , '🛠' , ['working_on_it' , 'hammer_and_wrench' , 'tools' ]),
236
+ candidate ('1f419' , '🐙' , ['octopus' ]),
237
+ ];
238
+ }
204
239
205
240
EmojiCandidate _emojiCandidateFor ({
206
241
required ReactionType emojiType,
@@ -264,6 +299,8 @@ class EmojiStoreImpl with EmojiStore {
264
299
return results;
265
300
}
266
301
302
+ List <EmojiCandidate >? _allEmojiCandidates;
303
+
267
304
@override
268
305
Iterable <EmojiCandidate > allEmojiCandidates () {
269
306
return _allEmojiCandidates ?? = _generateAllCandidates ();
0 commit comments