import { ExtendedMessage } from '@/atoms/im'
import ChatTextItem from './ChatTextItem'
import ChatLoadingContainer from './ChatLoadingContainer'
import ChatCustomItem from './ChatCustomItem'

const ChatMessageItems = ({ isUser, message }: { isUser: boolean; message: ExtendedMessage }) => {
  // 如果是loading消息，直接返回loading组件
  if (message.isLoadingMessage) {
    return <ChatLoadingContainer />
  }

  // 自定义消息
  // V2NIMMessageType.V2NIM_MESSAGE_TYPE_CUSTOM 100
  if (message.messageType === 100) {
    return <ChatCustomItem message={message} isUser={isUser} />
  }

  // 文本消息
  if (message.messageType === 0) {
    return <ChatTextItem isUser={isUser} message={message} />
  }

  return null
}

export default ChatMessageItems
