You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: show full list of reactions in a modal (#2249)
### 🎯 Goal
We're updating UI for displaying reactions. Instead of showing the
latest reactions only, we're adding a separate modal window full the
full list of reactions.
Although not a breaking change in terms of API, it's a breaking change
in terms of UI and styling.
### 🛠 Implementation details
1. New component `ReactionsListModal` is added (rendered by default
`ReactionsList`).
2. New handler added on message context level: `handleFetchReactions`.
It's expected to load all reactions for current message (e.g. using our
paged endpoint for fetching reactions). As usual, it can be overriden on
`Message` or `ReactionsList` level.
3. Instead of showing counts for the latest reactions only, we show
counts for all supported reactions in the `ReactionsList`.
### 🎨 UI Changes

### To-Do
- [x] Tests for ReactionsListModal
- [x] Add translations
This function limits the number of loaded reactions to 1200. To customize this behavior, you can pass [a custom `ReactionsList` component](../message-components/reactions.mdx#handlefetchreactions).
171
+
162
172
### handleFlag
163
173
164
174
Function that flags a message.
@@ -339,8 +349,8 @@ An array of users that have read the current message.
This function limits the number of loaded reactions to 1200. To customize this behavior, you can pass [a custom `ReactionsList` component](./reactions.mdx#handlefetchreactions).
299
+
290
300
### handleFlag
291
301
292
302
Function that flags a message (overrides the function stored in `MessageContext`).
@@ -352,6 +362,7 @@ Function that returns whether a message belongs to the current user (overrides t
352
362
| () => boolean |
353
363
354
364
### isReactionEnabled (deprecated)
365
+
355
366
If true, sending reactions is enabled in the currently active channel (overrides the value stored in `MessageContext`).
356
367
357
368
| Type | Default |
@@ -458,8 +469,8 @@ An array of users that have read the current message (overrides the value stored
458
469
459
470
Custom function to render message text content (overrides the function stored in `MessageContext`).
The default implementation of `handleFetchReactions`, provided via the [`MessageContext`](../contexts/message-context.mdx#handlefetchreactions), limits the number of loaded reactions to 1200. Use this prop to provide your own loading implementation:
A [custom hook](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/hooks/useReactionsFetcher.ts) to handle loading message reactions. Returns an async function that loads and returns message reactions.
// This example relies on react-query - but you can use you preferred method
194
+
// of fetching data instead
195
+
const { data } = useQuery(['message', message.id, 'reactions'], handleFetchReactions);
196
+
197
+
if (!data) {
198
+
return null;
199
+
}
200
+
201
+
return (
202
+
<>
203
+
{data.map((reaction) => (
204
+
<span key={reaction.type}>reaction.type</span>
205
+
))}
206
+
</>
207
+
);
208
+
};
209
+
```
210
+
211
+
This function limits the number of loaded reactions to 1200. To customize this behavior, provide [your own loader function](../message-components/reactions.mdx#handlefetchreactions) instead.
212
+
182
213
### useRetryHandler
183
214
184
215
A [custom hook](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/hooks/useRetryHandler.ts) to handle the retry of sending a message.
0 commit comments