Skip to content

Commit d90d848

Browse files
Initial commit
1 parent 2018e1a commit d90d848

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/components/Message/Message.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ const MessageWithContext = (props: MessageWithContextProps) => {
7272

7373
const { client, isMessageAIGenerated } = useChatContext('Message');
7474
const { channelConfig, read } = useChannelStateContext('Message');
75-
const { Message: contextMessage } = useComponentContext('Message');
75+
const {
76+
Message: contextMessage = DefaultMessageUI,
77+
// TODO: remove this passthrough once we drop Message from the ComponentContext
78+
MessageUI: contextMessageUI = contextMessage,
79+
} = useComponentContext('Message');
7680
const { getTranslationView, setTranslationView: setTranslationViewInContext } =
7781
useMessageTranslationViewContext();
7882

@@ -83,7 +87,7 @@ const MessageWithContext = (props: MessageWithContextProps) => {
8387
);
8488

8589
const actionsEnabled = message.type === 'regular' && message.status === 'received';
86-
const MessageUIComponent = propMessage ?? contextMessage ?? DefaultMessageUI;
90+
const MessageUIComponent = propMessage ?? contextMessageUI;
8791

8892
const { onUserClick, onUserHover } = useUserHandler(message, {
8993
onUserClickHandler: propOnUserClick,

src/components/Message/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ export type MessageProps = {
4141
// todo: could be moved to the Channel instance reactive state as lastReceivedMessage keeping the the receipt status as well (useful for channel preview)
4242
/** Latest message id on current channel */
4343
lastReceivedId?: string | null;
44-
/** UI component to display a Message in MessageList, overrides value in [ComponentContext](https://getstream.io/chat/docs/sdk/react/contexts/component_context/#message) */
45-
Message?: ComponentContextValue['Message'];
44+
/** UI component to display a Message in MessageList, overrides value in [ComponentContext](https://getstream.io/chat/docs/sdk/react/contexts/component_context/#message)
45+
* @deprecated use `ComponentContext` (`WithComponents`) component override instead (`MessageUI` slot)
46+
*/
47+
Message?: ComponentContextValue['MessageUI'];
4648
/** Array of allowed message actions (ex: ['edit', 'delete', 'flag', 'mute', 'pin', 'quote', 'react', 'reply']). To disable all actions, provide an empty array. */
4749
messageActions?: MessageActionsArray;
4850
/** DOMRect object for parent MessageList component */

src/context/ComponentContext.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ export type ComponentContextValue = {
158158
/** Custom UI component for determinate progress (0–100), defaults to and accepts same props as: [ProgressIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Loading/progress-indicators.tsx) */
159159
ProgressIndicator?: React.ComponentType<ProgressIndicatorProps>;
160160
/** Custom UI component to display a message in the standard `MessageList`, defaults to and accepts the same props as: [MessageUI](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageUI.tsx) */
161+
MessageUI?: React.ComponentType<MessageUIComponentProps>;
162+
/** Custom UI component to display a message in the standard `MessageList`, defaults to and accepts the same props as: [MessageUI](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageUI.tsx)
163+
* @deprecated use `MessageUI` instead
164+
*/
161165
Message?: React.ComponentType<MessageUIComponentProps>;
162166
/** Custom UI component for message actions popup, accepts no props, all the defaults are set within [MessageActions (unstable)](https://github.com/GetStream/stream-chat-react/blob/master/src/experimental/MessageActions/MessageActions.tsx) */
163167
MessageActions?: React.ComponentType;

0 commit comments

Comments
 (0)