mirror of
https://github.com/ianramzy/decentralized-video-chat.git
synced 2024-11-17 07:39:21 +08:00
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:
parent
4b92b8a538
commit
073d15070b
@ -765,16 +765,24 @@ chatInput.addEventListener("keypress", function (event) {
|
|||||||
// Make links clickable
|
// Make links clickable
|
||||||
msg = msg.autoLink();
|
msg = msg.autoLink();
|
||||||
// Send message over data channel
|
// Send message over data channel
|
||||||
|
if (isEmptyOrSpaces(msg) == false) {
|
||||||
dataChanel.send("mes:" + msg);
|
dataChanel.send("mes:" + msg);
|
||||||
// Add message to screen
|
|
||||||
addMessageToScreen(msg, true);
|
addMessageToScreen(msg, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
// Add message to screen
|
||||||
// Auto scroll chat down
|
// Auto scroll chat down
|
||||||
chatZone.scrollTop(chatZone[0].scrollHeight);
|
chatZone.scrollTop(chatZone[0].scrollHeight);
|
||||||
// Clear chat input
|
// Clear chat input
|
||||||
chatInput.value = "";
|
chatInput.value = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function isEmptyOrSpaces(str){
|
||||||
|
return str === null || str.match(/^ *$/) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
// Called when a message is recieved over the dataChannel
|
// Called when a message is recieved over the dataChannel
|
||||||
function handleRecieveMessage(msg) {
|
function handleRecieveMessage(msg) {
|
||||||
// Add message to screen
|
// Add message to screen
|
||||||
|
Loading…
Reference in New Issue
Block a user