From 89090cd3af63222c32cebae1b2094c92c2ef3681 Mon Sep 17 00:00:00 2001 From: Aditya Bansal Date: Wed, 28 Jun 2017 16:44:09 +0530 Subject: [PATCH] compose.js: Refactor validate_stream_message_address_info(). In this commit we just refactor validate_stream_message_address_info function to early return in case of stream_data.is_subscribed() returns true. --- static/js/compose.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/static/js/compose.js b/static/js/compose.js index 094ddd8438..d3108abf32 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -509,29 +509,29 @@ function validate_stream_message_mentions(stream_name) { } exports.validate_stream_message_address_info = function (stream_name) { - var response; - - if (!stream_data.is_subscribed(stream_name)) { - switch (check_stream_for_send(stream_name, page_params.narrow_stream !== undefined)) { - case "does-not-exist": - response = "

The stream " + - Handlebars.Utils.escapeExpression(stream_name) + " does not exist.

" + - "

Manage your subscriptions on your Streams page.

"; - compose_error(response, $('#stream')); - return false; - case "error": - compose_error(i18n.t("Error checking subscription"), $("#stream")); - return false; - case "not-subscribed": - response = "

You're not subscribed to the stream " + - Handlebars.Utils.escapeExpression(stream_name) + ".

" + - "

Manage your subscriptions on your Streams page.

"; - compose_error(response, $('#stream')); - return false; - } + if (stream_data.is_subscribed(stream_name)) { + return true; } - return true; + var response; + + switch (check_stream_for_send(stream_name, page_params.narrow_stream !== undefined)) { + case "does-not-exist": + response = "

The stream " + + Handlebars.Utils.escapeExpression(stream_name) + " does not exist.

" + + "

Manage your subscriptions on your Streams page.

"; + compose_error(response, $('#stream')); + return false; + case "error": + compose_error(i18n.t("Error checking subscription"), $("#stream")); + return false; + case "not-subscribed": + response = "

You're not subscribed to the stream " + + Handlebars.Utils.escapeExpression(stream_name) + ".

" + + "

Manage your subscriptions on your Streams page.

"; + compose_error(response, $('#stream')); + return false; + } }; function validate_stream_message() {