Skip to content

Commit

Permalink
Merge pull request #127 from abhiperfect/Fix/empty-message-issue
Browse files Browse the repository at this point in the history
Fix/Empty message being sent issue.
  • Loading branch information
SamarthKadam committed May 23, 2024
2 parents 7760674 + bfcbb5d commit fc1bdde
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/src/components/ChatComponents/Type.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function Type() {

const messageHandler = (e) => {
setMessage(e.target.value);

if (!message) return;
if (!socketConnected) return;

if (!typing) {
Expand Down Expand Up @@ -88,12 +88,13 @@ export default function Type() {
const sendMessage = async (event) => {
if (message.length === 0) return;

if (event.key === "Enter" || event.type === "click") {
if ((event.type === "keydown" && event.key === "Enter" && !event.shiftKey) || event.type === "click") {
event.preventDefault();
if (!message.trim()) return;
const cookie = localStorage.getItem("jwt");
const bodyData = {
chatId: isSet._id,
content: message,
content: message.trim()
};
setMessage("");
resetTranscript();
Expand Down

0 comments on commit fc1bdde

Please sign in to comment.