Skip to content

Commit

Permalink
[#130] Fix scroll to broadcast message as last message
Browse files Browse the repository at this point in the history
  • Loading branch information
wayangalihpratama committed Nov 4, 2024
1 parent abbd347 commit 97394fe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/src/components/chats/ChatWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const ClientChat = forwardRef(
);
ClientChat.displayName = "ClientChat";

const SystemChat = forwardRef(({ message, timestamp }, ref) => (
<div className="flex mb-4 justify-center" ref={ref}>
const SystemChat = forwardRef(({ message, timestamp, refTemp }, ref) => (
<div className="flex mb-4 justify-center" ref={refTemp}>
<div className="relative bg-blue-100 p-4 rounded-lg shadow-lg max-w-xs md:max-w-md">
{message?.split("\n")?.map((line, i) => (
<MarkdownRenderer
Expand All @@ -98,8 +98,8 @@ const SystemChat = forwardRef(({ message, timestamp }, ref) => (
));
SystemChat.displayName = "SystemChat";

const BroadcastChat = forwardRef(({ message, timestamp }, ref) => (
<div className="flex mb-4 justify-center" ref={ref}>
const BroadcastChat = forwardRef(({ message, timestamp, refTemp }, ref) => (
<div className="flex mb-4 justify-center" ref={refTemp}>
<div className="relative bg-orange-100 p-4 rounded-lg shadow-lg max-w-xs md:max-w-md">
{message?.split("\n")?.map((line, i) => (
<MarkdownRenderer
Expand Down Expand Up @@ -437,7 +437,7 @@ const ChatWindow = ({
key={`user-${ci}`}
message={c.body}
timestamp={c.conversation_envelope.timestamp}
ref={ci === chats.length - 1 ? lastMessageRef : null} // Attach ref to the last message
refTemp={ci === chats.length - 1 ? lastMessageRef : null}
/>
);
}
Expand Down

0 comments on commit 97394fe

Please sign in to comment.