Skip to content

Commit 376ac7d

Browse files
authored
feat: add support for membership customization (#2802)
* feat: add support for membership customization * fix: lint issues
1 parent 9c55bd5 commit 376ac7d

File tree

5 files changed

+24
-50
lines changed

5 files changed

+24
-50
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 & 48 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 {
@@ -70,17 +51,9 @@ const SendButtonWithContext = <
7051
);
7152
};
7253

73-
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,
81-
>(
82-
prevProps: NewDirectMessagingSendButtonPropsWithContext<At, Ch, Co, Ev, Me, Re, Us>,
83-
nextProps: NewDirectMessagingSendButtonPropsWithContext<At, Ch, Co, Ev, Me, Re, Us>,
54+
const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
55+
prevProps: NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>,
56+
nextProps: NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>,
8457
) => {
8558
const {
8659
disabled: prevDisabled,
@@ -117,23 +90,17 @@ const MemoizedNewDirectMessagingSendButton = React.memo(
11790
) as typeof SendButtonWithContext;
11891

11992
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>>;
93+
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
94+
> = Partial<NewDirectMessagingSendButtonPropsWithContext<StreamChatGenerics>>;
12895

12996
/**
13097
* UI Component for send button in MessageInput component.
13198
*/
132-
export const NewDirectMessagingSendButton = (props: SendButtonProps<StreamChatGenerics>) => {
99+
export const NewDirectMessagingSendButton = (props: SendButtonProps<LocalStreamChatGenerics>) => {
133100
const navigation = useNavigation<NewDirectMessagingScreenNavigationProp>();
134-
const { channel } = useChannelContext<StreamChatGenerics>();
101+
const { channel } = useChannelContext<LocalStreamChatGenerics>();
135102

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

138105
const sendMessage = async () => {
139106
if (!channel) {
@@ -152,7 +119,7 @@ export const NewDirectMessagingSendButton = (props: SendButtonProps<StreamChatGe
152119
};
153120

154121
return (
155-
<MemoizedNewDirectMessagingSendButton<StreamChatGenerics>
122+
<MemoizedNewDirectMessagingSendButton<LocalStreamChatGenerics>
156123
{...{ giphyActive, sendMessage }}
157124
{...props}
158125
{...{ 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
@@ -38,12 +38,14 @@ type LocalReactionType = Record<string, unknown>;
3838
type LocalUserType = Record<string, unknown>;
3939
type LocalPollOptionType = Record<string, unknown>;
4040
type LocalPollType = Record<string, unknown>;
41+
type LocalMemberType = Record<string, unknown>;
4142

4243
type StreamChatGenerics = {
4344
attachmentType: LocalAttachmentType;
4445
channelType: LocalChannelType;
4546
commandType: LocalCommandType;
4647
eventType: LocalEventType;
48+
memberType: LocalMemberType;
4749
messageType: LocalMessageType;
4850
pollOptionType: LocalPollOptionType;
4951
pollType: LocalPollType;

package/src/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export interface DefaultStreamChatGenerics extends ExtendableGenerics {
8282
channelType: DefaultChannelType;
8383
commandType: LiteralStringForUnion;
8484
eventType: UnknownType;
85+
memberType: UnknownType;
8586
messageType: UnknownType;
8687
reactionType: UnknownType;
8788
userType: DefaultUserType;

0 commit comments

Comments
 (0)