@@ -20,22 +20,12 @@ import 'store.dart';
2020///
2121/// Must have a [MessageListPage] ancestor.
2222void showMessageActionSheet ({required BuildContext context, required Message message}) {
23- final store = PerAccountStoreWidget .of (context);
24-
2523 // The UI that's conditioned on this won't live-update during this appearance
2624 // of the action sheet (we avoid calling composeBoxControllerOf in a build
2725 // method; see its doc). But currently it will be constant through the life of
2826 // any message list, so that's fine.
2927 final isComposeBoxOffered = MessageListPage .composeBoxControllerOf (context) != null ;
3028
31- // TODO filter away reactions by current user
32- // final hasThumbsUpReactionVote = message.reactions
33- // ?.aggregated.any((reactionWithVotes) =>
34- // reactionWithVotes.reactionType == ReactionType.unicodeEmoji
35- // && reactionWithVotes.emojiCode == '1f44d'
36- // && reactionWithVotes.userIds.contains(store.selfUserId))
37- // ?? false;
38-
3929 showDraggableScrollableModalBottomSheet (
4030 context: context,
4131 builder: (BuildContext _) {
@@ -103,7 +93,9 @@ class AddReactionButton extends MessageActionSheetMenuItemButton {
10393 padding: EdgeInsets .only (bottom: MediaQuery .of (emojiPickerContext).viewInsets.bottom),
10494 child: EmojiPicker (
10595 config: Config (
106- emojiSet: emojiSet,
96+ checkPlatformCompatibility: false ,
97+ emojiSet: getEmojiToDisplay (),
98+ // TODO figure out why tests fail without RecentTabBehavior.NONE
10799 categoryViewConfig: const CategoryViewConfig (recentTabBehavior: RecentTabBehavior .NONE )),
108100 onEmojiSelected: (_, Emoji ? emoji) async {
109101 if (emoji == null ) {
@@ -142,6 +134,18 @@ class AddReactionButton extends MessageActionSheetMenuItemButton {
142134 }));
143135 });
144136 };
137+
138+ /// Returns the emoji set to display in the emoji picker.
139+ List <CategoryEmoji > getEmojiToDisplay () {
140+ final selfUserId = PerAccountStoreWidget .of (messageListContext).selfUserId;
141+ final selfUserUnicodeReactions = message.reactions
142+ ? .aggregated.where ((reactionWithVotes) =>
143+ reactionWithVotes.reactionType == ReactionType .unicodeEmoji
144+ && reactionWithVotes.userIds.contains (selfUserId))
145+ .map ((reactionWithVotes) => reactionWithVotes.emojiName);
146+ return selfUserUnicodeReactions != null
147+ ? filterUnicodeEmojiSet (emojiSet, selfUserUnicodeReactions) : emojiSet;
148+ }
145149}
146150
147151class StarButton extends MessageActionSheetMenuItemButton {
0 commit comments