Automatically subscribe on send when lurking

(imported from commit 636c07346e766615a0012e4532f35d328bb7984d)
This commit is contained in:
Reid Barton 2013-01-16 14:03:33 -05:00
parent 64ebbc6c73
commit 2797a41fd8
2 changed files with 11 additions and 1 deletions

View File

@ -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();

View File

@ -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"));