Skip to content

Commit 9bda6ea

Browse files
authored
fix: export useFetchReaction hook from SDK and TS improvements (#2853)
1 parent 6738f3e commit 9bda6ea

File tree

3 files changed

+17
-28
lines changed

3 files changed

+17
-28
lines changed

package/src/components/MessageMenu/MessageReactionPicker.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FlatList, StyleSheet, View } from 'react-native';
33

44
import { ReactionButton } from './ReactionButton';
55

6+
import { MessageContextValue } from '../../contexts/messageContext/MessageContext';
67
import {
78
MessagesContextValue,
89
useMessagesContext,
@@ -16,23 +17,13 @@ import { ReactionData } from '../../utils/utils';
1617

1718
export type MessageReactionPickerProps<
1819
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
19-
> = Pick<MessagesContextValue<StreamChatGenerics>, 'supportedReactions'> & {
20-
/**
21-
* Function to dismiss the action bottom sheet.
22-
* @returns void
23-
*/
24-
dismissOverlay: () => void;
25-
/**
26-
* An array of reaction types that the current user has reacted with
27-
*/
28-
ownReactionTypes: string[];
29-
/**
30-
* Function to handle reaction on press
31-
* @param reactionType
32-
* @returns
33-
*/
34-
handleReaction?: (reactionType: string) => Promise<void>;
35-
};
20+
> = Pick<MessagesContextValue<StreamChatGenerics>, 'supportedReactions'> &
21+
Pick<MessageContextValue<StreamChatGenerics>, 'handleReaction' | 'dismissOverlay'> & {
22+
/**
23+
* An array of reaction types that the current user has reacted with
24+
*/
25+
ownReactionTypes: string[];
26+
};
3627

3728
export type ReactionPickerItemType = ReactionData & {
3829
onSelectReaction: (type: string) => void;

package/src/components/MessageMenu/MessageUserReactions.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ReactionSortBase } from 'stream-chat';
66
import { useFetchReactions } from './hooks/useFetchReactions';
77
import { ReactionButton } from './ReactionButton';
88

9+
import { MessageContextValue } from '../../contexts/messageContext/MessageContext';
910
import {
1011
MessagesContextValue,
1112
useMessagesContext,
@@ -14,7 +15,6 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
1415
import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
1516
import { DefaultStreamChatGenerics, Reaction } from '../../types/types';
1617
import { ReactionData } from '../../utils/utils';
17-
import { MessageType } from '../MessageList/hooks/useMessageList';
1818

1919
export type MessageUserReactionsProps<
2020
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -23,16 +23,13 @@ export type MessageUserReactionsProps<
2323
MessagesContextValue<StreamChatGenerics>,
2424
'MessageUserReactionsAvatar' | 'MessageUserReactionsItem' | 'supportedReactions'
2525
>
26-
> & {
27-
/**
28-
* The message object
29-
*/
30-
message?: MessageType<StreamChatGenerics>;
31-
/**
32-
* An array of reactions
33-
*/
34-
reactions?: Reaction[];
35-
};
26+
> &
27+
Partial<Pick<MessageContextValue<StreamChatGenerics>, 'message'>> & {
28+
/**
29+
* An array of reactions
30+
*/
31+
reactions?: Reaction[];
32+
};
3633

3734
const sort: ReactionSortBase = {
3835
created_at: -1,

package/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export * from './MessageMenu/MessageMenu';
162162
export * from './MessageMenu/MessageUserReactions';
163163
export * from './MessageMenu/MessageUserReactionsAvatar';
164164
export * from './MessageMenu/MessageReactionPicker';
165+
export * from './MessageMenu/hooks/useFetchReactions';
165166

166167
export * from './ProgressControl/ProgressControl';
167168
export * from './Poll';

0 commit comments

Comments
 (0)