Remove duplication in message validation

NB: this does change which error will be flagged if multiple conditions apply.

(imported from commit 080bf7d764f1f16ad57b365ad9aa6bc48f3cff72)
This commit is contained in:
Keegan McAllister
2012-10-31 17:18:48 -04:00
parent 366ca546e8
commit d6d34075ab

View File

@@ -231,11 +231,6 @@ function validate_stream_message() {
return false;
}
if (exports.message_content() === "") {
compose_error("You have nothing to send!", $("#new_message_content"));
return false;
}
if (!subs.have(stream_name)) {
if (!check_stream_for_send(stream_name)) {
return false;
@@ -259,17 +254,17 @@ function validate_huddle_message() {
return false;
}
if (exports.message_content() === "") {
compose_error("You have nothing to send!", $("#new_message_content"));
return false;
}
return true;
}
exports.validate = function () {
$("#compose-send-button").attr('disabled', 'disabled').blur();
if (exports.message_content() === "") {
compose_error("You have nothing to send!", $("#new_message_content"));
return false;
}
if (exports.composing() === 'huddle') {
return validate_huddle_message();
} else {