Skip to content

Commit fb8905c

Browse files
Merge pull request #105 from GetStream/vishal/thread-fixes
CRNS-48: Adding props for thread customization
2 parents f6b2a87 + dae67f3 commit fb8905c

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/components/Thread.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const NewThreadText = styled.Text`
2828
* The thread is only used for the list of replies to a message.
2929
*
3030
* Thread is a consumer of [channel context](https://getstream.github.io/stream-chat-react-native/#channelcontext)
31+
* Underlying MessageList, MessageInput and Message components can be customized using props:
32+
* - additionalParentMessageProps
33+
* - additionalMessageListProps
34+
* - additionalMessageInputProps
3135
*
3236
* @example ./docs/Thread.md
3337
* @extends Component
@@ -71,6 +75,21 @@ const Thread = withChannelContext(
7175
* **Available from [channel context](https://getstream.github.io/stream-chat-react-native/#channelcontext)**
7276
* If the thread is currently loading more messages. This is helpful to display a loading indicator on threadlist */
7377
threadLoadingMore: PropTypes.bool,
78+
/**
79+
* Additional props for underlying Message component of parent message at the top.
80+
* Available props - https://getstream.github.io/stream-chat-react-native/#message
81+
* */
82+
additionalParentMessageProps: PropTypes.object,
83+
/**
84+
* Additional props for underlying MessageList component.
85+
* Available props - https://getstream.github.io/stream-chat-react-native/#messagelist
86+
* */
87+
additionalMessageListProps: PropTypes.object,
88+
/**
89+
* Additional props for underlying MessageInput component.
90+
* Available props - https://getstream.github.io/stream-chat-react-native/#messageinput
91+
* */
92+
additionalMessageInputProps: PropTypes.object,
7493
};
7594

7695
static defaultProps = {
@@ -131,7 +150,9 @@ class ThreadInner extends React.PureComponent {
131150
readOnly
132151
groupStyles={['single']}
133152
Message={this.props.Message}
153+
// TODO: remove the following line in next release, since we already have additionalParentMessageProps now.
134154
{...this.props}
155+
{...this.props.additionalParentMessageProps}
135156
/>
136157
<NewThread>
137158
<NewThreadText>Start of a new thread</NewThreadText>
@@ -150,8 +171,13 @@ class ThreadInner extends React.PureComponent {
150171
hasMore={this.props.threadHasMore}
151172
loadingMore={this.props.threadLoadingMore}
152173
Message={this.props.Message}
174+
{...this.props.additionalMessageListProps}
175+
/>
176+
<MessageInput
177+
parent={this.props.thread}
178+
focus={this.props.autoFocus}
179+
{...this.props.additionalMessageInputProps}
153180
/>
154-
<MessageInput parent={this.props.thread} focus={this.props.autoFocus} />
155181
</React.Fragment>
156182
);
157183
}

types/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ interface ChannelListProps extends ChatContextValue {
245245
/** Object containing sort parameters */
246246
sort?: object;
247247
loadMoreThreshold?: number;
248+
additionalFlatListProps?: object;
248249
}
249250

250251
interface ChannelListState {
@@ -329,6 +330,7 @@ interface MessageListProps extends ChannelContextValue {
329330
/** https://github.com/beefe/react-native-actionsheet/blob/master/lib/styles.js */
330331
actionSheetStyles?: object;
331332
AttachmentFileIcon?: React.ElementType<FileIconUIComponentProps>;
333+
additionalFlatListProps?: object;
332334
}
333335

334336
declare type MessageAction = 'edit' | 'delete' | 'reactions' | 'reply';
@@ -408,6 +410,9 @@ interface ThreadProps extends ChannelContextValue {
408410
threadMessages?: Client.MessageResponse[];
409411
/** Make input focus on mounting thread */
410412
autoFocus?: boolean;
413+
additionalParentMessageProps?: object;
414+
additionalMessageListProps?: object;
415+
additionalMessageInputProps?: object;
411416
}
412417

413418
interface TypingIndicatorProps {

0 commit comments

Comments
 (0)