@@ -84,7 +84,7 @@ mixin EmojiStore {
8484  /// indexed by [Reaction.emojiCode] . 
8585Map <String , RealmEmojiItem > get  realmEmoji;
8686
87-   Iterable <EmojiCandidate >?   get  emojiCandidates ;
87+   Iterable <EmojiCandidate >  emojiCandidatesMatching ( String  query) ;
8888}
8989
9090/// The implementation of [EmojiStore]  that does the work. 
@@ -93,15 +93,36 @@ mixin EmojiStore {
9393/// itself.  Other code accesses this functionality through [PerAccountStore] , 
9494/// or through the mixin [EmojiStore]  which describes its interface. 
9595class  EmojiStoreImpl  with  EmojiStore  {
96-   EmojiStoreImpl ({required  this .realmEmoji});
96+   EmojiStoreImpl ({required  this .realmEmoji})
97+     :  _serverEmojiData =  {}; // TODO start with a built-in list; TODO fetch to update 
9798
9899  @override 
99100  Map <String , RealmEmojiItem > realmEmoji;
100101
101-   @override 
102-   List <EmojiCandidate >?  emojiCandidates;
102+   // ignore: prefer_final_fields 
103+   Map <String , List <String >> _serverEmojiData;
104+ 
105+   List <EmojiCandidate >?  _allEmojiCandidates;
103106
104-   // Map<String, List<String>> _serverEmojiData; 
107+   @override 
108+   Iterable <EmojiCandidate > emojiCandidatesMatching (String  query) {
109+     if  (query.isEmpty) {
110+       return  (_allEmojiCandidates ?? =  [
111+         // TODO fix this logic for when realm emoji overrides Unicode emoji 
112+         for  (final  entry in  _serverEmojiData.entries)
113+           UnicodeEmojiCandidate (
114+             emojiCode:  entry.key,
115+             emojiName:  entry.value.first,
116+             aliases:  entry.value.length >  1  ?  entry.value.sublist (1 ) :  null ,
117+             emojiUnicode:  tryParseEmojiCodeToUnicode (entry.key)! ,
118+           ),
119+         for  (final  entry in  realmEmoji.entries)
120+           RealmEmojiCandidate (emojiCode:  entry.key, emojiName:  entry.value.name),
121+         const  ZulipExtraEmojiCandidate (),
122+       ]);
123+     }
124+     throw  UnimplementedError (); // TODO filter emoji candidates 
125+   }
105126
106127  void  handleRealmEmojiUpdateEvent (RealmEmojiUpdateEvent  event) {
107128    realmEmoji =  event.realmEmoji;
0 commit comments