@@ -221,33 +221,45 @@ class EmojiStoreImpl extends PerAccountStoreBase with EmojiStore {
221
221
static final _popularCandidates = _generatePopularCandidates ();
222
222
223
223
static List <EmojiCandidate > _generatePopularCandidates () {
224
- EmojiCandidate candidate (String emojiCode, String emojiUnicode,
225
- List <String > names) {
224
+ EmojiCandidate candidate (String emojiCode, List <String > names) {
226
225
final emojiName = names.removeAt (0 );
227
- assert ( emojiUnicode == tryParseEmojiCodeToUnicode (emojiCode)) ;
226
+ final emojiUnicode = tryParseEmojiCodeToUnicode (emojiCode)! ;
228
227
return EmojiCandidate (emojiType: ReactionType .unicodeEmoji,
229
228
emojiCode: emojiCode, emojiName: emojiName, aliases: names,
230
229
emojiDisplay: UnicodeEmojiDisplay (
231
230
emojiName: emojiName, emojiUnicode: emojiUnicode));
232
231
}
232
+ final list = _popularEmojiCodesList;
233
233
return [
234
- // This list should match web:
235
- // https://github.com/zulip/zulip/blob/83a121c7e/web/shared/src/typeahead.ts#L22-L29
236
- candidate ('1f44d' , '👍' , ['+1' , 'thumbs_up' , 'like' ]),
237
- candidate ('1f389' , '🎉' , ['tada' ]),
238
- candidate ('1f642' , '🙂' , ['smile' ]),
239
- candidate ( '2764' , '❤' , ['heart' , 'love' , 'love_you' ]),
240
- candidate ('1f6e0' , '🛠' , ['working_on_it' , 'hammer_and_wrench' , 'tools' ]),
241
- candidate ('1f419' , '🐙' , ['octopus' ]),
234
+ candidate (list[0 ], ['+1' , 'thumbs_up' , 'like' ]),
235
+ candidate (list[1 ], ['tada' ]),
236
+ candidate (list[2 ], ['smile' ]),
237
+ candidate (list[3 ], ['heart' , 'love' , 'love_you' ]),
238
+ candidate (list[4 ], ['working_on_it' , 'hammer_and_wrench' , 'tools' ]),
239
+ candidate (list[5 ], ['octopus' ]),
242
240
];
243
241
}
244
242
245
- static final _popularEmojiCodes = (() {
246
- assert (_popularCandidates.every ((c) =>
247
- c.emojiType == ReactionType .unicodeEmoji));
248
- return Set .of (_popularCandidates.map ((c) => c.emojiCode));
243
+ /// Codes for the popular emoji, in order; all are Unicode emoji.
244
+ // This list should match web:
245
+ // https://github.com/zulip/zulip/blob/83a121c7e/web/shared/src/typeahead.ts#L22-L29
246
+ static final List <String > _popularEmojiCodesList = (() {
247
+ String check (String emojiCode, String emojiUnicode) {
248
+ assert (emojiUnicode == tryParseEmojiCodeToUnicode (emojiCode));
249
+ return emojiCode;
250
+ }
251
+ return [
252
+ check ('1f44d' , '👍' ),
253
+ check ('1f389' , '🎉' ),
254
+ check ('1f642' , '🙂' ),
255
+ check ('2764' , '❤' ),
256
+ check ('1f6e0' , '🛠' ),
257
+ check ('1f419' , '🐙' ),
258
+ ];
249
259
})();
250
260
261
+ static final Set <String > _popularEmojiCodes = Set .of (_popularEmojiCodesList);
262
+
251
263
static bool _isPopularEmoji (EmojiCandidate candidate) {
252
264
return candidate.emojiType == ReactionType .unicodeEmoji
253
265
&& _popularEmojiCodes.contains (candidate.emojiCode);
0 commit comments