Populate focused_recipient.to_user_ids in compose_fade.js.

This commit is contained in:
Steve Howell 2017-02-24 15:30:51 -08:00 committed by Tim Abbott
parent 4ae81d9063
commit 9791e2f570
2 changed files with 29 additions and 1 deletions

View File

@ -31,8 +31,10 @@ exports.set_focused_recipient = function (msg_type) {
} else {
// Normalize the recipient list so it matches the one used when
// adding the message (see message_store.add_message_metadata()).
focused_recipient.reply_to = util.normalize_recipients(
var reply_to = util.normalize_recipients(
$('#private_message_recipient').val());
focused_recipient.reply_to = reply_to;
focused_recipient.to_user_ids = people.reply_to_to_user_ids_string(reply_to);
}
};

View File

@ -150,6 +150,32 @@ exports.user_ids_string_to_emails_string = function (user_ids_string) {
return emails.join(',');
};
exports.reply_to_to_user_ids_string = function (emails_string) {
// This is basically emails_strings_to_user_ids_string
// without blueslip warnings, since it can be called with
// invalid data.
var emails = emails_string.split(',');
var user_ids = _.map(emails, function (email) {
var person = people.get_by_email(email);
if (person) {
return person.user_id;
}
});
if (!_.all(user_ids)) {
return;
}
user_ids.sort();
return user_ids.join(',');
};
exports.get_full_name = function (user_id) {
return people_by_user_id_dict.get(user_id).full_name;
};
exports.emails_strings_to_user_ids_string = function (emails_string) {
var emails = emails_string.split(',');
return exports.email_list_to_user_ids_string(emails);