Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
narrow_state: Remove narrowed_to_topic function.
evykassirer825fa6f0e1bb
diff --git a/web/src/compose_closed_ui.ts b/web/src/compose_closed_ui.tsindex 974ad8ed44b..5f435d03a46 100644--- a/web/src/compose_closed_ui.ts+++ b/web/src/compose_closed_ui.ts@@ -1,5 +1,4 @@import $ from "jquery";-import assert from "minimalistic-assert";import * as compose_actions from "./compose_actions";import {$t} from "./i18n";@@ -28,7 +27,6 @@ export function get_recipient_label(message?: ComposeClosedMessage): string {// actual message objects with fake objects containing just a// couple fields, both those constructed here and potentially// passed in.-if (message_lists.current === undefined) {return "";}@@ -38,12 +36,9 @@ export function get_recipient_label(message?: ComposeClosedMessage): string {// For empty narrows where there's a clear reply target,// i.e. stream+topic or a single direct message conversation,// we label the button as replying to the thread.- if (narrow_state.narrowed_to_topic()) {- const stream = narrow_state.stream_sub();- assert(stream !== undefined);- const stream_id = stream.stream_id;- const topic = narrow_state.topic();- assert(topic !== undefined);+ const stream_id = narrow_state.stream_sub()?.stream_id;+ const topic = narrow_state.topic();+ if (stream_id !== undefined && topic !== undefined) {return format_stream_recipient_label(stream_id, topic);} else if (narrow_state.pm_ids_string()) {const user_ids = people.user_ids_string_to_ids_array(narrow_state.pm_ids_string()!);diff --git a/web/src/narrow_state.ts b/web/src/narrow_state.tsindex 8e486ab0b59..4079fb25999 100644--- a/web/src/narrow_state.ts+++ b/web/src/narrow_state.ts@@ -138,6 +138,7 @@ export function stream_sub(return undefined;}const stream_operands = current_filter.operands("channel");+if (stream_operands.length !== 1) {return undefined;}@@ -357,13 +358,6 @@ export function narrowed_by_stream_reply(current_filter: Filter | undefined = fireturn terms.length === 1 && current_filter.operands("channel").length === 1;}-export function narrowed_to_topic(current_filter: Filter | undefined = filter()): boolean {- if (current_filter === undefined) {- return false;- }- return current_filter.has_operator("channel") && current_filter.has_operator("topic");-}-export function is_for_stream_id(stream_id: number, filter?: Filter): boolean {// This is not perfect, since we still track narrows by// name, not id, but at least the interface is good goingdiff --git a/web/tests/narrow_state.test.js b/web/tests/narrow_state.test.jsindex 86415548501..a1cfd01da1c 100644--- a/web/tests/narrow_state.test.js+++ b/web/tests/narrow_state.test.js@@ -74,7 +74,6 @@ test("narrowed", () => {assert.ok(!narrow_state.narrowed_by_reply());assert.ok(!narrow_state.narrowed_by_pm_reply());assert.ok(!narrow_state.narrowed_by_topic_reply());- assert.ok(!narrow_state.narrowed_to_topic());assert.ok(!narrow_state.narrowed_by_stream_reply());assert.equal(narrow_state.stream_sub(), undefined);@@ -83,7 +82,6 @@ test("narrowed", () => {assert.ok(!narrow_state.narrowed_by_reply());assert.ok(!narrow_state.narrowed_by_pm_reply());assert.ok(!narrow_state.narrowed_by_topic_reply());- assert.ok(!narrow_state.narrowed_to_topic());assert.ok(narrow_state.narrowed_by_stream_reply());set_filter([["dm", "[email protected]"]]);@@ -91,7 +89,6 @@ test("narrowed", () => {assert.ok(narrow_state.narrowed_by_reply());assert.ok(narrow_state.narrowed_by_pm_reply());assert.ok(!narrow_state.narrowed_by_topic_reply());- assert.ok(!narrow_state.narrowed_to_topic());assert.ok(!narrow_state.narrowed_by_stream_reply());set_filter([@@ -102,7 +99,6 @@ test("narrowed", () => {assert.ok(narrow_state.narrowed_by_reply());assert.ok(!narrow_state.narrowed_by_pm_reply());assert.ok(narrow_state.narrowed_by_topic_reply());- assert.ok(narrow_state.narrowed_to_topic());assert.ok(!narrow_state.narrowed_by_stream_reply());set_filter([["search", "grail"]]);@@ -110,7 +106,6 @@ test("narrowed", () => {assert.ok(!narrow_state.narrowed_by_reply());assert.ok(!narrow_state.narrowed_by_pm_reply());assert.ok(!narrow_state.narrowed_by_topic_reply());- assert.ok(!narrow_state.narrowed_to_topic());assert.ok(!narrow_state.narrowed_by_stream_reply());set_filter([["is", "starred"]]);@@ -118,7 +113,6 @@ test("narrowed", () => {assert.ok(!narrow_state.narrowed_by_reply());assert.ok(!narrow_state.narrowed_by_pm_reply());assert.ok(!narrow_state.narrowed_by_topic_reply());- assert.ok(!narrow_state.narrowed_to_topic());assert.ok(!narrow_state.narrowed_by_stream_reply());});