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