diff --git a/static/js/typing.js b/static/js/typing.js index 932644efbd..5bd1cc0f0c 100644 --- a/static/js/typing.js +++ b/static/js/typing.js @@ -7,12 +7,11 @@ var exports = {}; // // See docs/subsystems/typing-indicators.md for details on typing indicators. -function send_typing_notification_ajax(user_ids_string, operation) { - var typing_to = people.user_ids_string_to_emails_string(user_ids_string); +function send_typing_notification_ajax(user_ids_array, operation) { channel.post({ url: '/json/typing', data: { - to: typing_to, + to: JSON.stringify(user_ids_array), op: operation, }, success: function () {}, @@ -22,13 +21,13 @@ function send_typing_notification_ajax(user_ids_string, operation) { }); } -function get_user_ids_string() { +function get_user_ids_array() { var user_ids_string = compose_pm_pill.get_user_ids_string(); - if (user_ids_string === "") { return; } - return user_ids_string; + + return people.user_ids_string_to_ids_array(user_ids_string); } function is_valid_conversation(user_ids_string) { @@ -73,7 +72,7 @@ function notify_server_stop(user_ids_string) { exports.initialize = function () { var worker = { - get_recipient: get_user_ids_string, + get_recipient: get_user_ids_array, is_valid_conversation: is_valid_conversation, get_current_time: get_current_time, notify_server_start: notify_server_start, diff --git a/static/js/typing_status.js b/static/js/typing_status.js index 8fa4a4fd8d..84a7a89dd1 100644 --- a/static/js/typing_status.js +++ b/static/js/typing_status.js @@ -91,7 +91,9 @@ exports.handle_text_input = function (worker) { var current_recipient = exports.state.current_recipient; if (current_recipient) { - if (new_recipient === current_recipient) { + // We need to use _.isEqual for comparisons; === doesn't work + // on arrays. + if (_.isEqual(new_recipient, current_recipient)) { // Nothing has really changed, except we may need // to send a ping to the server. maybe_ping_server(worker, new_recipient); @@ -106,7 +108,6 @@ exports.handle_text_input = function (worker) { // so we must stop the old notification. Don't return // yet, because we may have a new recipient. stop_last_notification(worker); - } if (!worker.is_valid_conversation(new_recipient)) {