Skip to content

Commit 2e15334

Browse files
author
Dan Carbonell
committed
add custom system message component
1 parent ad1cb9c commit 2e15334

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/components/MessageList/MessageList.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { v4 as uuidv4 } from 'uuid';
66

77
import DefaultDateSeparator from './DateSeparator';
88
import MessageNotification from './MessageNotification';
9-
import MessageSystem from './MessageSystem';
9+
import DefaultMessageSystem from './MessageSystem';
1010
import DefaultTypingIndicator from './TypingIndicator';
1111
import TypingIndicatorContainer from './TypingIndicatorContainer';
1212

@@ -67,6 +67,7 @@ const MessageList = (props) => {
6767
disableWhileEditing = true,
6868
HeaderComponent,
6969
Message: MessageFromProps,
70+
MessageSystem = DefaultMessageSystem,
7071
messageActions,
7172
noGroupByUser,
7273
onThreadSelect,
@@ -310,6 +311,11 @@ MessageList.propTypes = {
310311
* */
311312
Message: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
312313
messageActions: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]),
314+
/**
315+
* Custom UI component to display a system message
316+
* Default component (accepts the same props): [MessageSystem](https://getstream.github.io/stream-chat-react-native/#messagesystem)
317+
*/
318+
MessageSystem: PropTypes.oneOfType([PropTypes.node, PropTypes.elementType]),
313319
/**
314320
* Boolean weather current message list is a thread.
315321
*/

src/components/MessageList/MessageSystem.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useContext } from 'react';
22
import styled from '@stream-io/styled-components';
3+
import PropTypes from 'prop-types';
34

45
import { TranslationContext } from '../../context';
56

@@ -63,4 +64,9 @@ const MessageSystem = ({ message }) => {
6364
);
6465
};
6566

67+
MessageSystem.propTypes = {
68+
/** Current [message object](https://getstream.io/chat/docs/#message_format) */
69+
message: PropTypes.object.isRequired,
70+
};
71+
6672
export default MessageSystem;

styleguide.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module.exports = {
6565
'src/components/MessageList/EventIndicator.js',
6666
'src/components/MessageList/MessageList.js',
6767
'src/components/MessageList/MessageNotification.js',
68+
'src/components/MessageList/MessageSystem.js',
6869
'src/components/MessageList/TypingIndicator.js',
6970
],
7071
exampleMode: 'collapse',
@@ -104,7 +105,7 @@ module.exports = {
104105
'src/components/MessageInput/UploadProgressIndicator.js',
105106
],
106107
exampleMode: 'collapse',
107-
name: 'Message Input',
108+
name: 'MessageInput Components',
108109
usageMode: 'expand',
109110
},
110111
{
@@ -193,7 +194,7 @@ module.exports = {
193194
},
194195
{
195196
exampleMode: 'collapse',
196-
name: 'Custom UI component props',
197+
name: 'Custom UI Component Props',
197198
sections: [
198199
{
199200
content: 'src/components/docs/AttachmentProps.md',

0 commit comments

Comments
 (0)