diff --git a/frontend/src/components/MessageInput.jsx b/frontend/src/components/MessageInput.jsx index 934c66f..c8cb900 100644 --- a/frontend/src/components/MessageInput.jsx +++ b/frontend/src/components/MessageInput.jsx @@ -10,14 +10,12 @@ import { Clapperboard, BarChart2, } from "lucide-react"; - import toast from "react-hot-toast"; import { useChatStore } from "../store/useChatStore"; import EmojiPicker from "emoji-picker-react"; import GifPicker from "./GifPicker"; import PollCreatorModal from "./PollCreatorModal"; - const MessageInput = () => { const [text, setText] = useState(""); const [imagePreview, setImagePreview] = useState(null); @@ -29,7 +27,6 @@ const MessageInput = () => { const [dragActive, setDragActive] = useState(false); const [showPollModal, setShowPollModal] = useState(false); - const emojiRef = useRef(null); const gifRef = useRef(null); const fileRef = useRef(null); @@ -52,8 +49,8 @@ const MessageInput = () => { smartReplies, } = useChatStore(); - const isAI = selectedChatType === "private" && selectedUser?.isAI; + const hasContent = Boolean(text.trim() || imagePreview || fileData || audioData); useEffect(() => { return () => { @@ -133,7 +130,7 @@ const MessageInput = () => { const reader = new FileReader(); reader.onload = () => setAudioData(reader.result); reader.readAsDataURL(blob); - stream.getTracks().forEach((track) => track.stop()); // Clean up hardware use + stream.getTracks().forEach((track) => track.stop()); }; mediaRecorder.start(); @@ -164,7 +161,7 @@ const MessageInput = () => { const handleSend = async (e) => { e.preventDefault(); - if (!text.trim() && !imagePreview && !fileData && !audioData) return; + if (!hasContent) return; stopTyping(); @@ -184,13 +181,10 @@ const MessageInput = () => { : await sendMessage(payload); } - // Reset all states setText(""); setImagePreview(null); setFileData(null); setAudioData(null); - - // useChatStore.setState({ smartReplies: [] }); }; const handleDragOver = (e) => { @@ -229,55 +223,57 @@ const MessageInput = () => { return (
- Drop file to upload +
+ Drop file here to upload
- Suggested Replies -
- - {/* Replies */} -