// Copyright 2024, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 import { Markdown } from "@/app/element/markdown"; import clsx from "clsx"; import { OverlayScrollbarsComponent } from "overlayscrollbars-react"; import { memo, useEffect, useRef } from "react"; import "./chatmessages.scss"; export interface ChatMessage { id: string; username: string; message: string; color?: string; userIcon?: string; } interface ChatMessagesProps { messages: ChatMessage[]; className?: string; } const ChatMessages = memo(({ messages, className }: ChatMessagesProps) => { const messagesEndRef = useRef(null); const overlayScrollRef = useRef(null); const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); }; useEffect(() => { // scrollToBottom(); }, [messages]); return ( {messages.map(({ id, username, message, color, userIcon }) => (
{userIcon && user icon} {username}:
))}
); }); ChatMessages.displayName = "ChatMessages"; export { ChatMessages };