Skip to content

Commit

Permalink
community chat not working now
Browse files Browse the repository at this point in the history
  • Loading branch information
lizzie authored and lizzie committed Nov 20, 2024
1 parent a767b78 commit 14c3cec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
17 changes: 0 additions & 17 deletions client/src/components/main/chat/SendMessage.tsx

This file was deleted.

1 change: 0 additions & 1 deletion client/src/components/main/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const ChatPage = () => {
</span>
) : (
<>
{/* <div className='chat-title'> */}
<div className='search-container'>
<span className='chat-title'>chatting now: </span>
<input
Expand Down
11 changes: 9 additions & 2 deletions client/src/hooks/useChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const useChat = () => {
.filter(curr => curr.toLowerCase() !== user.username);

const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setSend(e.target.value);
setSearchTerm(e.target.value);
setDropdownOpen(true); // Open the dropdown when typing
};
Expand Down Expand Up @@ -54,16 +55,22 @@ const useChat = () => {
useEffect(() => {
if (pathname.includes('community')) {
setSend(community || '');
setSearchTerm(community || '');
}
}, [community, pathname, setSend]);
}, [community, pathname, setSend, setSearchTerm]);

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setCurrentMessage(e.target.value);
};

const saveMessagesToUserAccount = async (message: string, sendTo: string) => {
try {
if (user && user.username) {
if (
user &&
user.username &&
listOfUsers.includes(sendTo) &&
listOfUsers.includes(searchTerm)
) {
await addDoc(collection(db, 'messages'), {
username: user.username,
message,
Expand Down

0 comments on commit 14c3cec

Please sign in to comment.