11import './index.scss' ;
22import React from 'react' ;
33
4- import type { GroupChannelUIProps } from '.' ;
54import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext' ;
65
7- import GroupChannelHeader , { type GroupChannelHeaderProps } from '../GroupChannelHeader' ;
8- import MessageList from '../MessageList' ;
96import TypingIndicator from '../TypingIndicator' ;
107import { TypingIndicatorType } from '../../../../types' ;
118import ConnectionStatus from '../../../../ui/ConnectionStatus' ;
129import PlaceHolder , { PlaceHolderTypes } from '../../../../ui/PlaceHolder' ;
13- import MessageInputWrapper from '../MessageInputWrapper' ;
1410
15- export interface GroupChannelUIViewProps extends GroupChannelUIProps , GroupChannelHeaderProps {
16- requestedChannelUrl : string ;
11+ import type { RenderCustomSeparatorProps , RenderMessageParamsType } from '../../../../types' ;
12+ import type { GroupChannelHeaderProps } from '../GroupChannelHeader' ;
13+ import type { GroupChannelMessageListProps } from '../MessageList' ;
14+ import type { MessageContentProps } from '../../../../ui/MessageContent' ;
15+
16+ export interface GroupChannelUIBasicProps {
17+ // Components
18+ renderPlaceholderLoader ?: ( ) => React . ReactElement ;
19+ renderPlaceholderInvalid ?: ( ) => React . ReactElement ;
20+ renderPlaceholderEmpty ?: ( ) => React . ReactElement ;
21+ renderChannelHeader ?: ( props : GroupChannelHeaderProps ) => React . ReactElement ;
22+ renderMessageList ?: ( props : GroupChannelMessageListProps ) => React . ReactElement ;
23+ renderMessageInput ?: ( ) => React . ReactElement ;
24+
25+ // Sub components
26+ // MessageList
27+ renderMessage ?: ( props : RenderMessageParamsType ) => React . ReactElement ;
28+ renderMessageContent ?: ( props : MessageContentProps ) => React . ReactElement ;
29+ renderCustomSeparator ?: ( props : RenderCustomSeparatorProps ) => React . ReactElement ;
30+ renderFrozenNotification ?: ( ) => React . ReactElement ;
31+
32+ // MessageInput
33+ renderFileUploadIcon ?: ( ) => React . ReactElement ;
34+ renderVoiceMessageIcon ?: ( ) => React . ReactElement ;
35+ renderSendMessageIcon ?: ( ) => React . ReactElement ;
36+ renderTypingIndicator ?: ( ) => React . ReactElement ;
37+ }
38+
39+ export interface GroupChannelUIViewProps extends GroupChannelUIBasicProps {
1740 loading : boolean ;
1841 isInvalid : boolean ;
42+ channelUrl : string ;
43+ renderChannelHeader : GroupChannelUIBasicProps [ 'renderChannelHeader' ] ;
44+ renderMessageList : GroupChannelUIBasicProps [ 'renderMessageList' ] ;
45+ renderMessageInput : GroupChannelUIBasicProps [ 'renderMessageInput' ] ;
1946}
2047
2148export const GroupChannelUIView = ( props : GroupChannelUIViewProps ) => {
2249 const {
23- requestedChannelUrl,
2450 loading,
2551 isInvalid,
26- renderChannelHeader = ( props ) => (
27- < GroupChannelHeader { ...props } />
28- ) ,
29- renderMessageList = ( props ) => (
30- < MessageList
31- { ...props }
32- className = "sendbird-conversation__message-list"
33- />
34- ) ,
35- renderMessageInput = ( ) => < MessageInputWrapper /> ,
52+ channelUrl,
53+ renderChannelHeader,
54+ renderMessageList,
55+ renderMessageInput,
3656 renderTypingIndicator,
3757 renderPlaceholderLoader,
3858 renderPlaceholderInvalid,
3959 } = props ;
60+
4061 const { stores, config } = useSendbirdStateContext ( ) ;
4162 const sdkError = stores ?. sdkStore ?. error ;
4263 const { logger, isOnline } = config ;
@@ -45,9 +66,9 @@ export const GroupChannelUIView = (props: GroupChannelUIViewProps) => {
4566 return < div className = "sendbird-conversation" > { renderPlaceholderLoader ?.( ) || < PlaceHolder type = { PlaceHolderTypes . LOADING } /> } </ div > ;
4667 }
4768
48- if ( ! requestedChannelUrl ) {
69+ if ( ! channelUrl ) {
4970 return (
50- < div className = "sendbird-conversation" > { renderPlaceholderInvalid ?.( ) || < PlaceHolder type = { PlaceHolderTypes . NO_CHANNELS } /> } </ div >
71+ < div className = "sendbird-conversation" > { renderPlaceholderInvalid ?.( ) || < PlaceHolder type = { PlaceHolderTypes . NO_CHANNELS } /> } </ div >
5172 ) ;
5273 }
5374
@@ -72,21 +93,16 @@ export const GroupChannelUIView = (props: GroupChannelUIViewProps) => {
7293 }
7394
7495 return (
75- < div className = ' sendbird-conversation' >
96+ < div className = " sendbird-conversation" >
7697 { renderChannelHeader ?.( { className : 'sendbird-conversation__channel-header' } ) }
7798 { renderMessageList ?.( props ) }
7899 < div className = "sendbird-conversation__footer" >
79100 { renderMessageInput ?.( ) }
80101 < div className = "sendbird-conversation__footer__typing-indicator" >
81102 { renderTypingIndicator ?.( )
82- || (
83- config ?. groupChannel ?. enableTypingIndicator
84- && config ?. groupChannel ?. typingIndicatorTypes ?. has ( TypingIndicatorType . Text )
85- && (
86- < TypingIndicator channelUrl = { requestedChannelUrl } />
87- )
88- )
89- }
103+ || ( config ?. groupChannel ?. enableTypingIndicator && config ?. groupChannel ?. typingIndicatorTypes ?. has ( TypingIndicatorType . Text ) && (
104+ < TypingIndicator channelUrl = { channelUrl } />
105+ ) ) }
90106 { ! isOnline && < ConnectionStatus /> }
91107 </ div >
92108 </ div >
0 commit comments