From cf7ed970c369ed2b1cf22b15b5a1c6bee263c6ec Mon Sep 17 00:00:00 2001 From: HoonBaek Date: Wed, 18 May 2022 13:55:50 +0900 Subject: [PATCH 1/2] Fix typo: Separator --- src/index.d.ts | 6 +++--- .../Channel/components/ChannelUI/index.tsx | 6 +++--- .../Channel/components/Message/index.tsx | 14 ++++++++++---- .../Channel/components/MessageList/index.tsx | 6 +++--- src/smart-components/Channel/index.tsx | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index a1b9d49d0..90f7226bb 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -609,7 +609,7 @@ interface ChannelUIProps { renderMessage?: (props: RenderMessageProps) => React.ComponentType; renderMessageInput?: () => React.ReactNode; renderTypingIndicator?: () => React.ReactNode; - renderCustomSeperator?: () => React.ReactNode; + renderCustomSeparator?: () => React.ReactNode; } type CoreMessageType = Sendbird.AdminMessage | Sendbird.UserMessage | Sendbird.FileMessage; @@ -659,7 +659,7 @@ type MessageUIProps = { handleScroll: () => void; // for extending renderMessage?: (props: RenderMessageProps) => React.ReactNode; - renderCustomSeperator?: () => React.ReactNode; + renderCustomSeparator?: () => React.ReactNode; renderEditInput?: () => React.ReactNode; renderMessageContent?: () => React.ReactNode; }; @@ -667,7 +667,7 @@ type MessageUIProps = { type MessageListProps = { renderMessage?: (props: RenderMessageProps) => React.ReactNode; renderPlaceholderEmpty?: () => React.ReactNode; - renderCustomSeperator?: () => React.ReactNode; + renderCustomSeparator?: () => React.ReactNode; }; type SuggestedMentionListProps = { diff --git a/src/smart-components/Channel/components/ChannelUI/index.tsx b/src/smart-components/Channel/components/ChannelUI/index.tsx index 93dd91963..e7641fe13 100644 --- a/src/smart-components/Channel/components/ChannelUI/index.tsx +++ b/src/smart-components/Channel/components/ChannelUI/index.tsx @@ -23,7 +23,7 @@ export interface ChannelUIProps { renderMessage?: (props: RenderMessageProps) => React.ReactNode; renderMessageInput?: () => React.ReactNode; renderTypingIndicator?: () => React.ReactNode; - renderCustomSeperator?: () => React.ReactNode; + renderCustomSeparator?: () => React.ReactNode; } const ChannelUI: React.FC = ({ @@ -34,7 +34,7 @@ const ChannelUI: React.FC = ({ renderMessage, renderMessageInput, renderTypingIndicator, - renderCustomSeperator, + renderCustomSeparator, }: ChannelUIProps) => { const { currentGroupChannel, @@ -143,7 +143,7 @@ const ChannelUI: React.FC = ({ ) } diff --git a/src/smart-components/Channel/components/Message/index.tsx b/src/smart-components/Channel/components/Message/index.tsx index ad2a74674..48af11c4c 100644 --- a/src/smart-components/Channel/components/Message/index.tsx +++ b/src/smart-components/Channel/components/Message/index.tsx @@ -32,7 +32,7 @@ type MessageUIProps = { handleScroll: () => void; // for extending renderMessage?: (props: RenderMessageProps) => React.ReactNode; - renderCustomSeperator?: () => React.ReactNode; + renderCustomSeparator?: () => React.ReactNode; renderEditInput?: () => React.ReactNode; renderMessageContent?: () => React.ReactNode; }; @@ -44,7 +44,7 @@ const Message: React.FC = (props: MessageUIProps) => { chainTop, chainBottom, handleScroll, - renderCustomSeperator, + renderCustomSeparator, renderEditInput, renderMessage, renderMessageContent, @@ -160,6 +160,12 @@ const Message: React.FC = (props: MessageUIProps) => { chainBottom, }); }, [message, renderMessage]); + const renderedCustomSeparator = useMemo(() => { + if (renderCustomSeparator) { + return renderCustomSeparator?.(); + } + return null; + }, [message, renderCustomSeparator]); if (renderedMessage) { return ( @@ -174,7 +180,7 @@ const Message: React.FC = (props: MessageUIProps) => { {/* date-separator */} { // TODO: Add message instance as a function parameter - hasSeparator && renderCustomSeperator?.() || ( + hasSeparator && renderedCustomSeparator || (