compose: Avoid render for duplicate mentions.

There is no reason to render the template for compose mention
warnings if the user is already in the widget.

This commit also restructures the unit test significantly to more
carefully exercise each case, particularly in regard to when
templates get rendered.
This commit is contained in:
Steve Howell
2017-07-09 08:13:42 -04:00
parent 05a21b3729
commit 1cf18cfbeb
2 changed files with 83 additions and 28 deletions

View File

@@ -653,8 +653,6 @@ exports.initialize = function () {
}
if (compose_fade.would_receive_message(email) === false) {
var new_row = templates.render("compose-invite-users",
{email: email, name: data.mentioned.full_name});
var error_area = $("#compose_invite_users");
var existing_invites_area = $('#compose_invite_users .compose_invite_user');
@@ -663,6 +661,8 @@ exports.initialize = function () {
});
if (existing_invites.indexOf(email) === -1) {
var context = {email: email, name: data.mentioned.full_name};
var new_row = templates.render("compose-invite-users", context);
error_area.append(new_row);
}