mirror of https://github.com/zulip/zulip.git
filter: Show pm_with title with near narrow links.
Updates the `filter.get_title` logic to return the list of users for narrows that include the pm_with and near operators. That way the browser/tab title remains the same for these views.
This commit is contained in:
parent
bcd1763dca
commit
0901ccdb47
|
@ -1481,6 +1481,15 @@ test("navbar_helpers", () => {
|
|||
// not common narrows, but used for browser title updates
|
||||
const is_alerted = [{operator: "is", operand: "alerted"}];
|
||||
const is_unread = [{operator: "is", operand: "unread"}];
|
||||
const stream_topic_near = [
|
||||
{operator: "stream", operand: "foo"},
|
||||
{operator: "topic", operand: "bar"},
|
||||
{operator: "near", operand: "12"},
|
||||
];
|
||||
const pm_with_near = [
|
||||
{operator: "pm-with", operand: "joe@example.com"},
|
||||
{operator: "near", operand: "12"},
|
||||
];
|
||||
|
||||
const test_cases = [
|
||||
{
|
||||
|
@ -1615,6 +1624,20 @@ test("navbar_helpers", () => {
|
|||
title: "translated: Unread messages",
|
||||
redirect_url_with_search: "#",
|
||||
},
|
||||
{
|
||||
operator: stream_topic_near,
|
||||
is_common_narrow: false,
|
||||
icon: "hashtag",
|
||||
title: "Foo",
|
||||
redirect_url_with_search: "#",
|
||||
},
|
||||
{
|
||||
operator: pm_with_near,
|
||||
is_common_narrow: false,
|
||||
icon: "envelope",
|
||||
title: properly_separated_names([joe.full_name]),
|
||||
redirect_url_with_search: "#",
|
||||
},
|
||||
];
|
||||
|
||||
for (const test_case of test_cases) {
|
||||
|
|
|
@ -672,6 +672,23 @@ export class Filter {
|
|||
}
|
||||
return this._sub.name;
|
||||
}
|
||||
if (
|
||||
(term_types.length === 2 && _.isEqual(term_types, ["pm-with", "near"])) ||
|
||||
(term_types.length === 1 && _.isEqual(term_types, ["pm-with"]))
|
||||
) {
|
||||
const emails = this.operands("pm-with")[0].split(",");
|
||||
const names = emails.map((email) => {
|
||||
if (!people.get_by_email(email)) {
|
||||
return email;
|
||||
}
|
||||
return people.get_by_email(email).full_name;
|
||||
});
|
||||
|
||||
// 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(", ");
|
||||
}
|
||||
if (term_types.length === 1) {
|
||||
switch (term_types[0]) {
|
||||
case "in-home":
|
||||
|
@ -692,20 +709,6 @@ export class Filter {
|
|||
return $t({defaultMessage: "Mentions"});
|
||||
case "is-private":
|
||||
return $t({defaultMessage: "Private messages"});
|
||||
case "pm-with": {
|
||||
const emails = this.operands("pm-with")[0].split(",");
|
||||
const names = emails.map((email) => {
|
||||
if (!people.get_by_email(email)) {
|
||||
return email;
|
||||
}
|
||||
return people.get_by_email(email).full_name;
|
||||
});
|
||||
|
||||
// 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(", ");
|
||||
}
|
||||
case "is-resolved":
|
||||
return $t({defaultMessage: "Topics marked as resolved"});
|
||||
// These cases return false for is_common_narrow, and therefore are not
|
||||
|
|
Loading…
Reference in New Issue