diff --git a/examples/ExpoMessaging/types.ts b/examples/ExpoMessaging/types.ts index 5128439cb4..6607eb8e63 100644 --- a/examples/ExpoMessaging/types.ts +++ b/examples/ExpoMessaging/types.ts @@ -5,14 +5,16 @@ export type LocalEventType = Record; export type LocalMessageType = Record; export type LocalReactionType = Record; export type LocalUserType = Record; -type LocalPollOptionType = Record; -type LocalPollType = Record; +export type LocalPollOptionType = Record; +export type LocalPollType = Record; +export type LocalMemberType = Record; export type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx b/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx index a0c8d716aa..557820c634 100644 --- a/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx +++ b/examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx @@ -4,18 +4,11 @@ import { TouchableOpacity } from 'react-native-gesture-handler'; import { useNavigation } from '@react-navigation/core'; import { - DefaultAttachmentType, - DefaultChannelType, - DefaultCommandType, - DefaultEventType, - DefaultMessageType, - DefaultReactionType, - DefaultUserType, + DefaultStreamChatGenerics, MessageInputContextValue, Search, SendRight, SendUp, - UnknownType, useChannelContext, useMessageInputContext, useTheme, @@ -23,30 +16,18 @@ import { import { NewDirectMessagingScreenNavigationProp } from '../screens/NewDirectMessagingScreen'; -import { StreamChatGenerics } from '../types'; +import { StreamChatGenerics as LocalStreamChatGenerics } from '../types'; type NewDirectMessagingSendButtonPropsWithContext< - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, -> = Pick, 'giphyActive' | 'sendMessage'> & { + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, +> = Pick, 'giphyActive' | 'sendMessage'> & { /** Disables the button */ disabled: boolean; }; const SendButtonWithContext = < - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, >( - props: NewDirectMessagingSendButtonPropsWithContext, + props: NewDirectMessagingSendButtonPropsWithContext, ) => { const { disabled = false, giphyActive, sendMessage } = props; const { @@ -70,17 +51,9 @@ const SendButtonWithContext = < ); }; -const areEqual = < - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, ->( - prevProps: NewDirectMessagingSendButtonPropsWithContext, - nextProps: NewDirectMessagingSendButtonPropsWithContext, +const areEqual = ( + prevProps: NewDirectMessagingSendButtonPropsWithContext, + nextProps: NewDirectMessagingSendButtonPropsWithContext, ) => { const { disabled: prevDisabled, @@ -117,23 +90,17 @@ const MemoizedNewDirectMessagingSendButton = React.memo( ) as typeof SendButtonWithContext; export type SendButtonProps< - At extends UnknownType = DefaultAttachmentType, - Ch extends UnknownType = DefaultChannelType, - Co extends string = DefaultCommandType, - Ev extends UnknownType = DefaultEventType, - Me extends UnknownType = DefaultMessageType, - Re extends UnknownType = DefaultReactionType, - Us extends UnknownType = DefaultUserType, -> = Partial>; + StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics, +> = Partial>; /** * UI Component for send button in MessageInput component. */ -export const NewDirectMessagingSendButton = (props: SendButtonProps) => { +export const NewDirectMessagingSendButton = (props: SendButtonProps) => { const navigation = useNavigation(); - const { channel } = useChannelContext(); + const { channel } = useChannelContext(); - const { giphyActive, text } = useMessageInputContext(); + const { giphyActive, text } = useMessageInputContext(); const sendMessage = async () => { if (!channel) { @@ -152,7 +119,7 @@ export const NewDirectMessagingSendButton = (props: SendButtonProps + {...{ giphyActive, sendMessage }} {...props} {...{ disabled: props.disabled || false }} diff --git a/examples/SampleApp/src/types.ts b/examples/SampleApp/src/types.ts index 25467f87d3..fb95c6a0e4 100644 --- a/examples/SampleApp/src/types.ts +++ b/examples/SampleApp/src/types.ts @@ -17,12 +17,14 @@ export type LocalUserType = { }; type LocalPollOptionType = Record; type LocalPollType = Record; +type LocalMemberType = Record; export type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/examples/TypeScriptMessaging/App.tsx b/examples/TypeScriptMessaging/App.tsx index 44bd02155a..7cb110d2af 100644 --- a/examples/TypeScriptMessaging/App.tsx +++ b/examples/TypeScriptMessaging/App.tsx @@ -38,12 +38,14 @@ type LocalReactionType = Record; type LocalUserType = Record; type LocalPollOptionType = Record; type LocalPollType = Record; +type LocalMemberType = Record; type StreamChatGenerics = { attachmentType: LocalAttachmentType; channelType: LocalChannelType; commandType: LocalCommandType; eventType: LocalEventType; + memberType: LocalMemberType; messageType: LocalMessageType; pollOptionType: LocalPollOptionType; pollType: LocalPollType; diff --git a/package/src/types/types.ts b/package/src/types/types.ts index 3ff97c89f6..f9ef9d0ed7 100644 --- a/package/src/types/types.ts +++ b/package/src/types/types.ts @@ -82,6 +82,7 @@ export interface DefaultStreamChatGenerics extends ExtendableGenerics { channelType: DefaultChannelType; commandType: LiteralStringForUnion; eventType: UnknownType; + memberType: UnknownType; messageType: UnknownType; reactionType: UnknownType; userType: DefaultUserType;