Skip to content

Commit

Permalink
fix: export useFetchReaction hook from SDK and TS improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Dec 13, 2024
1 parent 5d81a97 commit 4ba678d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
25 changes: 8 additions & 17 deletions package/src/components/MessageMenu/MessageReactionPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlatList, StyleSheet, View } from 'react-native';

import { ReactionButton } from './ReactionButton';

import { MessageContextValue } from '../../contexts/messageContext/MessageContext';
import {
MessagesContextValue,
useMessagesContext,
Expand All @@ -16,23 +17,13 @@ import { ReactionData } from '../../utils/utils';

export type MessageReactionPickerProps<
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
> = Pick<MessagesContextValue<StreamChatGenerics>, 'supportedReactions'> & {
/**
* Function to dismiss the action bottom sheet.
* @returns void
*/
dismissOverlay: () => void;
/**
* An array of reaction types that the current user has reacted with
*/
ownReactionTypes: string[];
/**
* Function to handle reaction on press
* @param reactionType
* @returns
*/
handleReaction?: (reactionType: string) => Promise<void>;
};
> = Pick<MessagesContextValue<StreamChatGenerics>, 'supportedReactions'> &
Pick<MessageContextValue<StreamChatGenerics>, 'handleReaction' | 'dismissOverlay'> & {
/**
* An array of reaction types that the current user has reacted with
*/
ownReactionTypes: string[];
};

export type ReactionPickerItemType = ReactionData & {
onSelectReaction: (type: string) => void;
Expand Down
19 changes: 8 additions & 11 deletions package/src/components/MessageMenu/MessageUserReactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ReactionSortBase } from 'stream-chat';
import { useFetchReactions } from './hooks/useFetchReactions';
import { ReactionButton } from './ReactionButton';

import { MessageContextValue } from '../../contexts/messageContext/MessageContext';
import {
MessagesContextValue,
useMessagesContext,
Expand All @@ -14,7 +15,6 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
import { useTranslationContext } from '../../contexts/translationContext/TranslationContext';
import { DefaultStreamChatGenerics, Reaction } from '../../types/types';
import { ReactionData } from '../../utils/utils';
import { MessageType } from '../MessageList/hooks/useMessageList';

export type MessageUserReactionsProps<
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
Expand All @@ -23,16 +23,13 @@ export type MessageUserReactionsProps<
MessagesContextValue<StreamChatGenerics>,
'MessageUserReactionsAvatar' | 'MessageUserReactionsItem' | 'supportedReactions'
>
> & {
/**
* The message object
*/
message?: MessageType<StreamChatGenerics>;
/**
* An array of reactions
*/
reactions?: Reaction[];
};
> &
Partial<Pick<MessageContextValue<StreamChatGenerics>, 'message'>> & {
/**
* An array of reactions
*/
reactions?: Reaction[];
};

const sort: ReactionSortBase = {
created_at: -1,
Expand Down
1 change: 1 addition & 0 deletions package/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export * from './MessageMenu/MessageMenu';
export * from './MessageMenu/MessageUserReactions';
export * from './MessageMenu/MessageUserReactionsAvatar';
export * from './MessageMenu/MessageReactionPicker';
export * from './MessageMenu/hooks/useFetchReactions';

export * from './ProgressControl/ProgressControl';
export * from './Poll';
Expand Down

0 comments on commit 4ba678d

Please sign in to comment.