Add typing.initialize() to prevent tracebacks.

We now wait to start typing notifications until everything else
is initialized.  This prevents traceback where things like compose
pills have not been initialized.
This commit is contained in:
Steve Howell
2018-03-16 07:39:46 -04:00
committed by Tim Abbott
parent 6d85f8c9ef
commit 9105692b07
2 changed files with 21 additions and 18 deletions

View File

@@ -73,26 +73,28 @@ function notify_server_stop(recipients) {
send_typing_notification_ajax(recipients, "stop");
}
var worker = {
get_recipient: get_recipient,
is_valid_conversation: is_valid_conversation,
get_current_time: get_current_time,
notify_server_start: notify_server_start,
notify_server_stop: notify_server_stop,
exports.initialize = function () {
var worker = {
get_recipient: get_recipient,
is_valid_conversation: is_valid_conversation,
get_current_time: get_current_time,
notify_server_start: notify_server_start,
notify_server_stop: notify_server_stop,
};
$(document).on('input', '#compose-textarea', function () {
// If our previous state was no typing notification, send a
// start-typing notice immediately.
typing_status.handle_text_input(worker);
});
// We send a stop-typing notification immediately when compose is
// closed/cancelled
$(document).on('compose_canceled.zulip compose_finished.zulip', function () {
typing_status.stop(worker);
});
};
$(document).on('input', '#compose-textarea', function () {
// If our previous state was no typing notification, send a
// start-typing notice immediately.
typing_status.handle_text_input(worker);
});
// We send a stop-typing notification immediately when compose is
// closed/cancelled
$(document).on('compose_canceled.zulip compose_finished.zulip', function () {
typing_status.stop(worker);
});
return exports;
}());

View File

@@ -283,6 +283,7 @@ $(function () {
hotspots.initialize();
ui.initialize();
panels.initialize();
typing.initialize();
});