filter: Use ', ' to separate names in PM title.

This is a prep commit for the navbar redesign.
This commit is contained in:
YashRE42 2020-04-10 01:23:29 +05:30 committed by Tim Abbott
parent 497383cc12
commit 5fdb8989e5
2 changed files with 13 additions and 4 deletions

View File

@ -1319,6 +1319,11 @@ function make_private_sub(name, stream_id) {
}
run_test('navbar_helpers', () => {
// make sure title has names separated with correct delimiters
function properly_separated_names(names) {
return names.join(', ');
}
function test_redirect_url_with_search(test_case) {
test_case.operator.push({ operator: 'search', operand: 'fizzbuzz'});
const filter = new Filter(test_case.operator);
@ -1436,21 +1441,21 @@ run_test('navbar_helpers', () => {
operator: pm_with,
is_common_narrow: true,
icon: 'envelope',
title: [joe.full_name],
title: properly_separated_names([joe.full_name]),
redirect_url_with_search: '/#narrow/pm-with/' + joe.user_id + '-' + joe.email.split('@')[0],
},
{
operator: group_pm,
is_common_narrow: true,
icon: 'envelope',
title: [joe.full_name, steve.full_name],
title: properly_separated_names([joe.full_name, steve.full_name]),
redirect_url_with_search: '/#narrow/pm-with/' + joe.user_id + ',' + steve.user_id + '-group',
},
{
operator: group_pm_including_missing_person,
is_common_narrow: true,
icon: 'envelope',
title: [joe.full_name, steve.full_name, 'sally@doesnotexist.com'],
title: properly_separated_names([joe.full_name, steve.full_name, 'sally@doesnotexist.com']),
redirect_url_with_search: '/#narrow/pm-with/undefined',
},
];

View File

@ -573,7 +573,11 @@ Filter.prototype = {
}
return people.get_by_email(email).full_name;
});
return names;
// We use join to handle the addition of a comma and space after every name
// and also to ensure that we return a string and not an array so that we
// can have the same return type as other cases.
return names.join(', ');
}
}
}