Only send message if generalChannel is available

Ensure generalChannel is available before attempting to send a message
This commit is contained in:
Kevin Ndung'u Gathuku
2017-11-19 16:06:24 +03:00
committed by GitHub
parent a74841e9ec
commit 8804492089

View File

@@ -98,7 +98,7 @@ $(function() {
// Send a new message to the general channel // Send a new message to the general channel
var $input = $('#chat-input'); var $input = $('#chat-input');
$input.on('keydown', function(e) { $input.on('keydown', function(e) {
if (e.keyCode == 13) { if (e.keyCode == 13 && generalChannel) {
generalChannel.sendMessage($input.val()) generalChannel.sendMessage($input.val())
$input.val(''); $input.val('');
} }