Skip to content

Commit 14e003f

Browse files
committed
feat: add support for membership customization
1 parent 6568ff8 commit 14e003f

File tree

5 files changed

+24
-48
lines changed

5 files changed

+24
-48
lines changed

examples/ExpoMessaging/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ export type LocalEventType = Record<string, unknown>;
55
export type LocalMessageType = Record<string, unknown>;
66
export type LocalReactionType = Record<string, unknown>;
77
export type LocalUserType = Record<string, unknown>;
8-
type LocalPollOptionType = Record<string, unknown>;
9-
type LocalPollType = Record<string, unknown>;
8+
export type LocalPollOptionType = Record<string, unknown>;
9+
export type LocalPollType = Record<string, unknown>;
10+
export type LocalMemberType = Record<string, unknown>;
1011

1112
export type StreamChatGenerics = {
1213
attachmentType: LocalAttachmentType;
1314
channelType: LocalChannelType;
1415
commandType: LocalCommandType;
1516
eventType: LocalEventType;
17+
memberType: LocalMemberType;
1618
messageType: LocalMessageType;
1719
pollOptionType: LocalPollOptionType;
1820
pollType: LocalPollType;

examples/SampleApp/src/components/NewDirectMessagingSendButton.tsx

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,30 @@ import { TouchableOpacity } from 'react-native-gesture-handler';
44
import { useNavigation } from '@react-navigation/core';
55

66
import {
7-
DefaultAttachmentType,
8-
DefaultChannelType,
9-
DefaultCommandType,
10-
DefaultEventType,
11-
DefaultMessageType,
12-
DefaultReactionType,
13-
DefaultUserType,
7+
DefaultStreamChatGenerics,
148
MessageInputContextValue,
159
Search,
1610
SendRight,
1711
SendUp,
18-
UnknownType,
1912
useChannelContext,
2013
useMessageInputContext,
2114
useTheme,
2215
} from 'stream-chat-react-native';
2316

2417
import { NewDirectMessagingScreenNavigationProp } from '../screens/NewDirectMessagingScreen';
2518

26-
import { StreamChatGenerics } from '../types';
19+
import { StreamChatGenerics as LocalStreamChatGenerics } from '../types';
2720

2821
type NewDirectMessagingSendButtonPropsWithContext<
29-
At extends UnknownType = DefaultAttachmentType,
30-
Ch extends UnknownType = DefaultChannelType,
31-
Co extends string = DefaultCommandType,
32-
Ev extends UnknownType = DefaultEventType,
33-
Me extends UnknownType = DefaultMessageType,
34-
Re extends UnknownType = DefaultReactionType,
35-
Us extends UnknownType = DefaultUserType,
36-
> = Pick<MessageInputContextValue<At, Ch, Co, Ev, Me, Re, Us>, 'giphyActive' | 'sendMessage'> & {
22+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
23+
> = Pick<MessageInputContextValue<StreamChatGenerics>, 'giphyActive' | 'sendMessage'> & {
3724
/** Disables the button */ disabled: boolean;
3825
};
3926

4027
const SendButtonWithContext = <
41-
At extends UnknownType = DefaultAttachmentType,
42-
Ch extends UnknownType = DefaultChannelType,
43-
Co extends string = DefaultCommandType,
44-
Ev extends UnknownType = DefaultEventType,
45-
Me extends UnknownType = DefaultMessageType,
46-
Re extends UnknownType = DefaultReactionType,
47-
Us extends UnknownType = DefaultUserType,
28+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
4829
>(
49-
props: NewDirectMessagingSendButtonPropsWithContext<At, Ch, Co, Ev, Me, Re, Us>,
30+
props: NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>,
5031
) => {
5132
const { disabled = false, giphyActive, sendMessage } = props;
5233
const {
@@ -71,16 +52,10 @@ const SendButtonWithContext = <
7152
};
7253

7354
const areEqual = <
74-
At extends UnknownType = DefaultAttachmentType,
75-
Ch extends UnknownType = DefaultChannelType,
76-
Co extends string = DefaultCommandType,
77-
Ev extends UnknownType = DefaultEventType,
78-
Me extends UnknownType = DefaultMessageType,
79-
Re extends UnknownType = DefaultReactionType,
80-
Us extends UnknownType = DefaultUserType,
55+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
8156
>(
82-
prevProps: NewDirectMessagingSendButtonPropsWithContext<At, Ch, Co, Ev, Me, Re, Us>,
83-
nextProps: NewDirectMessagingSendButtonPropsWithContext<At, Ch, Co, Ev, Me, Re, Us>,
57+
prevProps: NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>,
58+
nextProps: NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>,
8459
) => {
8560
const {
8661
disabled: prevDisabled,
@@ -117,23 +92,17 @@ const MemoizedNewDirectMessagingSendButton = React.memo(
11792
) as typeof SendButtonWithContext;
11893

11994
export type SendButtonProps<
120-
At extends UnknownType = DefaultAttachmentType,
121-
Ch extends UnknownType = DefaultChannelType,
122-
Co extends string = DefaultCommandType,
123-
Ev extends UnknownType = DefaultEventType,
124-
Me extends UnknownType = DefaultMessageType,
125-
Re extends UnknownType = DefaultReactionType,
126-
Us extends UnknownType = DefaultUserType,
127-
> = Partial<NewDirectMessagingSendButtonPropsWithContext<At, Ch, Co, Ev, Me, Re, Us>>;
95+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
96+
> = Partial<NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>>;
12897

12998
/**
13099
* UI Component for send button in MessageInput component.
131100
*/
132-
export const NewDirectMessagingSendButton = (props: SendButtonProps<StreamChatGenerics>) => {
101+
export const NewDirectMessagingSendButton = (props: SendButtonProps<LocalStreamChatGenerics>) => {
133102
const navigation = useNavigation<NewDirectMessagingScreenNavigationProp>();
134-
const { channel } = useChannelContext<StreamChatGenerics>();
103+
const { channel } = useChannelContext<LocalStreamChatGenerics>();
135104

136-
const { giphyActive, text } = useMessageInputContext<StreamChatGenerics>();
105+
const { giphyActive, text } = useMessageInputContext<LocalStreamChatGenerics>();
137106

138107
const sendMessage = async () => {
139108
if (!channel) {
@@ -152,7 +121,7 @@ export const NewDirectMessagingSendButton = (props: SendButtonProps<StreamChatGe
152121
};
153122

154123
return (
155-
<MemoizedNewDirectMessagingSendButton<StreamChatGenerics>
124+
<MemoizedNewDirectMessagingSendButton<LocalStreamChatGenerics>
156125
{...{ giphyActive, sendMessage }}
157126
{...props}
158127
{...{ disabled: props.disabled || false }}

examples/SampleApp/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ export type LocalUserType = {
1717
};
1818
type LocalPollOptionType = Record<string, unknown>;
1919
type LocalPollType = Record<string, unknown>;
20+
type LocalMemberType = Record<string, unknown>;
2021

2122
export type StreamChatGenerics = {
2223
attachmentType: LocalAttachmentType;
2324
channelType: LocalChannelType;
2425
commandType: LocalCommandType;
2526
eventType: LocalEventType;
27+
memberType: LocalMemberType;
2628
messageType: LocalMessageType;
2729
pollOptionType: LocalPollOptionType;
2830
pollType: LocalPollType;

examples/TypeScriptMessaging/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ type LocalReactionType = Record<string, unknown>;
3636
type LocalUserType = Record<string, unknown>;
3737
type LocalPollOptionType = Record<string, unknown>;
3838
type LocalPollType = Record<string, unknown>;
39+
type LocalMemberType = Record<string, unknown>;
3940

4041
type StreamChatGenerics = {
4142
attachmentType: LocalAttachmentType;
4243
channelType: LocalChannelType;
4344
commandType: LocalCommandType;
4445
eventType: LocalEventType;
46+
memberType: LocalMemberType;
4547
messageType: LocalMessageType;
4648
pollOptionType: LocalPollOptionType;
4749
pollType: LocalPollType;

package/src/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export interface DefaultStreamChatGenerics extends ExtendableGenerics {
8989
channelType: DefaultChannelType;
9090
commandType: LiteralStringForUnion;
9191
eventType: UnknownType;
92+
memberType: UnknownType;
9293
messageType: UnknownType;
9394
reactionType: UnknownType;
9495
userType: DefaultUserType;

0 commit comments

Comments
 (0)