mirror of https://github.com/zulip/zulip.git
typing indicators: Use user ids internally.
We now ask compose_pm_pill to give us a list of user ids that we are PM'ing to, and we only convert user ids to emails right before we put requests on the wire. We also let the "pill system" tell us whether we have unconverted data. It also sets up for an upcoming server change where we can just send user ids to the server. This change should be transparent to the majority of users. For Zephyr users we are slightly less aggressive about sending typing indicators, since we now require valid user ids.
This commit is contained in:
parent
c0edcf6fe4
commit
72295e94b4
|
@ -7,11 +7,12 @@ 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(recipients, operation) {
|
function send_typing_notification_ajax(user_ids_string, 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: recipients,
|
to: typing_to,
|
||||||
op: operation,
|
op: operation,
|
||||||
},
|
},
|
||||||
success: function () {},
|
success: function () {},
|
||||||
|
@ -21,21 +22,26 @@ function send_typing_notification_ajax(recipients, operation) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_recipient() {
|
function get_user_ids_string() {
|
||||||
var compose_recipient = compose_state.recipient();
|
var user_ids_string = compose_pm_pill.get_user_ids_string();
|
||||||
if (compose_recipient === "") {
|
|
||||||
|
if (user_ids_string === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return compose_recipient;
|
return user_ids_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_valid_conversation(recipient) {
|
function is_valid_conversation(user_ids_string) {
|
||||||
// TODO: Check to make sure we're in a PM conversation
|
// TODO: Check to make sure we're in a PM conversation
|
||||||
// with valid emails.
|
// with valid emails.
|
||||||
if (!recipient) {
|
if (!user_ids_string) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (compose_pm_pill.has_unconverted_data()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var compose_empty = !compose_state.has_message_content();
|
var compose_empty = !compose_state.has_message_content();
|
||||||
if (compose_empty) {
|
if (compose_empty) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -50,14 +56,6 @@ function is_valid_conversation(recipient) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compose.get_invalid_recipient_emails().length > 0) {
|
|
||||||
// If we have invalid recipient emails, it's highly
|
|
||||||
// likely the user is either still deciding who to
|
|
||||||
// compose to, or is confused. Also, the server
|
|
||||||
// will just reject our requests.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,17 +63,17 @@ function get_current_time() {
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
function notify_server_start(recipients) {
|
function notify_server_start(user_ids_string) {
|
||||||
send_typing_notification_ajax(recipients, "start");
|
send_typing_notification_ajax(user_ids_string, "start");
|
||||||
}
|
}
|
||||||
|
|
||||||
function notify_server_stop(recipients) {
|
function notify_server_stop(user_ids_string) {
|
||||||
send_typing_notification_ajax(recipients, "stop");
|
send_typing_notification_ajax(user_ids_string, "stop");
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
var worker = {
|
var worker = {
|
||||||
get_recipient: get_recipient,
|
get_recipient: get_user_ids_string,
|
||||||
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,
|
||||||
|
|
Loading…
Reference in New Issue