diff --git a/zephyr/static/js/compose.js b/zephyr/static/js/compose.js index 10894e3eb5..7f6ab227ca 100644 --- a/zephyr/static/js/compose.js +++ b/zephyr/static/js/compose.js @@ -302,6 +302,15 @@ function validate_stream_message() { // browser window doesn't know it. return true; case "not-subscribed": + if (lurk_stream.toLowerCase() === stream_name.toLowerCase()) { + // Just subscribe them. + subs.subscribe_for_send(stream_name); + // When the subscription request completes, + // subscribe_for_send will send our message (like when + // the user clicks on subscribe-and-send). + return false; + } + $('#send-status').removeClass(status_classes); $('#stream-nosub-name').text(stream_name); $('#stream-nosub').show(); diff --git a/zephyr/static/js/subs.js b/zephyr/static/js/subs.js index 0e4de7cad3..0b1b73d35f 100644 --- a/zephyr/static/js/subs.js +++ b/zephyr/static/js/subs.js @@ -183,7 +183,8 @@ exports.subscribe_for_send = function (stream, prompt_button) { success: function (response) { add_to_stream_list(stream); compose.finish(); - prompt_button.stop(true).fadeOut(500); + if (prompt_button !== undefined) + prompt_button.stop(true).fadeOut(500); }, error: function (xhr, error_type, exn) { ui.report_error("Unable to subscribe", xhr, $("#home-error"));