Skip to content

Commit e9f0c94

Browse files
committed
Added the no conv thing
1 parent 8ccdf44 commit e9f0c94

1 file changed

Lines changed: 12 additions & 22 deletions

File tree

LocalMind-Backend/src/chats/ChatList.jsx

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react';
22
import ChatMessage from './ChatMessage';
33
import TypingIndicator from './TypingIndicator';
44

5-
export default function ChatList({ messages = [], isTyping = false, onStartNewChat }) {
5+
export default function ChatList({ messages = [], isTyping = false }) {
66
const containerRef = useRef(null);
77

88
useEffect(() => {
@@ -12,29 +12,19 @@ export default function ChatList({ messages = [], isTyping = false, onStartNewCh
1212
container.scrollTo({ top: container.scrollHeight, behavior: 'smooth' });
1313
}, [messages, isTyping]);
1414

15-
// Show empty state when no messages exist
16-
if (messages.length === 0) {
17-
return (
18-
<main className="flex-1 flex flex-col items-center justify-center px-4 py-6">
19-
<div className="text-center max-w-xs">
20-
<p className="text-gray-500 mb-4">No chats yet. Start a new conversation!</p>
21-
{onStartNewChat && (
22-
<button
23-
onClick={onStartNewChat}
24-
className="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors"
25-
>
26-
New Chat
27-
</button>
28-
)}
29-
</div>
30-
</main>
31-
);
32-
}
33-
3415
return (
3516
<main ref={containerRef} className="flex-1 overflow-y-auto px-4 py-6 space-y-4 scroll-smooth">
3617
<div className="flex flex-col gap-4">
37-
{messages.map((m) => <ChatMessage key={m.id} message={m} />)}
18+
{messages.length === 0 ? (
19+
<div className="text-center text-gray-500 dark:text-gray-400">
20+
<p>No messages yet.</p>
21+
<p>Start a conversation with your friends.</p>
22+
</div>
23+
) : (
24+
messages.map((message, index) => (
25+
<ChatMessage key={index} message={message} />
26+
))
27+
)}
3828
{isTyping && (
3929
<div className="flex justify-start">
4030
<TypingIndicator />
@@ -43,4 +33,4 @@ export default function ChatList({ messages = [], isTyping = false, onStartNewCh
4333
</div>
4434
</main>
4535
);
46-
}
36+
}

0 commit comments

Comments
 (0)