Only send message if its not null or not empty

This PR is raised to address the empty messages being sent in zipcall .

How to check the problem:-
1) Initiate a zipcall session
2) open chat 
3) continuously press enter,  you will be able to see multiple empty messages which is sent in the UI
This commit is contained in:
Prajith Kesava Prasad 2020-10-03 21:13:49 +05:30 committed by GitHub
parent 4b92b8a538
commit 073d15070b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -765,16 +765,24 @@ chatInput.addEventListener("keypress", function (event) {
// Make links clickable
msg = msg.autoLink();
// Send message over data channel
if (isEmptyOrSpaces(msg) == false) {
dataChanel.send("mes:" + msg);
// Add message to screen
addMessageToScreen(msg, true);
}
// Add message to screen
// Auto scroll chat down
chatZone.scrollTop(chatZone[0].scrollHeight);
// Clear chat input
chatInput.value = "";
}
});
function isEmptyOrSpaces(str){
return str === null || str.match(/^ *$/) !== null;
}
// Called when a message is recieved over the dataChannel
function handleRecieveMessage(msg) {
// Add message to screen