@@ -20,22 +20,12 @@ import 'store.dart';
20
20
///
21
21
/// Must have a [MessageListPage] ancestor.
22
22
void showMessageActionSheet ({required BuildContext context, required Message message}) {
23
- final store = PerAccountStoreWidget .of (context);
24
-
25
23
// The UI that's conditioned on this won't live-update during this appearance
26
24
// of the action sheet (we avoid calling composeBoxControllerOf in a build
27
25
// method; see its doc). But currently it will be constant through the life of
28
26
// any message list, so that's fine.
29
27
final isComposeBoxOffered = MessageListPage .composeBoxControllerOf (context) != null ;
30
28
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
-
39
29
showDraggableScrollableModalBottomSheet (
40
30
context: context,
41
31
builder: (BuildContext _) {
@@ -103,7 +93,9 @@ class AddReactionButton extends MessageActionSheetMenuItemButton {
103
93
padding: EdgeInsets .only (bottom: MediaQuery .of (emojiPickerContext).viewInsets.bottom),
104
94
child: EmojiPicker (
105
95
config: Config (
106
- emojiSet: emojiSet,
96
+ checkPlatformCompatibility: false ,
97
+ emojiSet: getEmojiToDisplay (),
98
+ // TODO figure out why tests fail without RecentTabBehavior.NONE
107
99
categoryViewConfig: const CategoryViewConfig (recentTabBehavior: RecentTabBehavior .NONE )),
108
100
onEmojiSelected: (_, Emoji ? emoji) async {
109
101
if (emoji == null ) {
@@ -142,6 +134,18 @@ class AddReactionButton extends MessageActionSheetMenuItemButton {
142
134
}));
143
135
});
144
136
};
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
+ }
145
149
}
146
150
147
151
class StarButton extends MessageActionSheetMenuItemButton {
0 commit comments