Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export useFetchReaction hook from SDK and TS improvements #2853

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading