filter: Show stream and topic title for near link narrows.

Updates the `filter.get_title` logic to return the stream name for
narrows that include the stream, topic and near operators. That
way the browser/tab title remains the same for these views, which
have a particular scroll offset.
This commit is contained in:
Lauryn Menard 2022-10-26 17:58:40 +02:00 committed by Tim Abbott
parent ca36f23d9f
commit 7172a6ef13
1 changed files with 4 additions and 1 deletions

View File

@ -662,7 +662,10 @@ export class Filter {
get_title() {
// Nice explanatory titles for common views.
const term_types = this.sorted_term_types();
if (term_types.length === 2 && _.isEqual(term_types, ["stream", "topic"])) {
if (
(term_types.length === 3 && _.isEqual(term_types, ["stream", "topic", "near"])) ||
(term_types.length === 2 && _.isEqual(term_types, ["stream", "topic"]))
) {
if (!this._sub) {
const search_text = this.operands("stream")[0];
return $t({defaultMessage: "Unknown stream #{search_text}"}, {search_text});