mirror of https://github.com/zulip/zulip.git
typing: Use user IDs instead of user ids string.
This commit is contained in:
parent
5228403eb5
commit
b8250fc61e
|
@ -7,12 +7,11 @@ var exports = {};
|
||||||
//
|
//
|
||||||
// See docs/subsystems/typing-indicators.md for details on typing indicators.
|
// See docs/subsystems/typing-indicators.md for details on typing indicators.
|
||||||
|
|
||||||
function send_typing_notification_ajax(user_ids_string, operation) {
|
function send_typing_notification_ajax(user_ids_array, operation) {
|
||||||
var typing_to = people.user_ids_string_to_emails_string(user_ids_string);
|
|
||||||
channel.post({
|
channel.post({
|
||||||
url: '/json/typing',
|
url: '/json/typing',
|
||||||
data: {
|
data: {
|
||||||
to: typing_to,
|
to: JSON.stringify(user_ids_array),
|
||||||
op: operation,
|
op: operation,
|
||||||
},
|
},
|
||||||
success: function () {},
|
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();
|
var user_ids_string = compose_pm_pill.get_user_ids_string();
|
||||||
|
|
||||||
if (user_ids_string === "") {
|
if (user_ids_string === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return user_ids_string;
|
|
||||||
|
return people.user_ids_string_to_ids_array(user_ids_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_valid_conversation(user_ids_string) {
|
function is_valid_conversation(user_ids_string) {
|
||||||
|
@ -73,7 +72,7 @@ function notify_server_stop(user_ids_string) {
|
||||||
|
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
var worker = {
|
var worker = {
|
||||||
get_recipient: get_user_ids_string,
|
get_recipient: get_user_ids_array,
|
||||||
is_valid_conversation: is_valid_conversation,
|
is_valid_conversation: is_valid_conversation,
|
||||||
get_current_time: get_current_time,
|
get_current_time: get_current_time,
|
||||||
notify_server_start: notify_server_start,
|
notify_server_start: notify_server_start,
|
||||||
|
|
|
@ -91,7 +91,9 @@ exports.handle_text_input = function (worker) {
|
||||||
var current_recipient = exports.state.current_recipient;
|
var current_recipient = exports.state.current_recipient;
|
||||||
|
|
||||||
if (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
|
// Nothing has really changed, except we may need
|
||||||
// to send a ping to the server.
|
// to send a ping to the server.
|
||||||
maybe_ping_server(worker, new_recipient);
|
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
|
// so we must stop the old notification. Don't return
|
||||||
// yet, because we may have a new recipient.
|
// yet, because we may have a new recipient.
|
||||||
stop_last_notification(worker);
|
stop_last_notification(worker);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!worker.is_valid_conversation(new_recipient)) {
|
if (!worker.is_valid_conversation(new_recipient)) {
|
||||||
|
|
Loading…
Reference in New Issue