Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

stream_data: Remove is_stream_muted_by_name to favor stream ids.

evykassirer90cced31afa1
diff --git a/web/src/stream_data.ts b/web/src/stream_data.ts
index 62e94d5178b..96f8817c3ba 100644
--- a/web/src/stream_data.ts
+++ b/web/src/stream_data.ts
@@ -462,15 +462,6 @@ export function is_muted(stream_id: number): boolean {
return sub.is_muted;
}
-export function is_stream_muted_by_name(stream_name: string): boolean {
- const sub = get_sub(stream_name);
- // Return true for undefined streams
- if (sub === undefined) {
- return true;
- }
- return sub.is_muted;
-}
-
export function is_new_stream_announcements_stream_muted(): boolean {
return is_muted(realm.realm_new_stream_announcements_stream_id);
}
diff --git a/web/src/topic_generator.ts b/web/src/topic_generator.ts
index e71f065423c..a9bf4c52077 100644
--- a/web/src/topic_generator.ts
+++ b/web/src/topic_generator.ts
@@ -67,13 +67,13 @@ export function get_next_topic(
let my_streams = stream_list_sort.get_streams();
my_streams = my_streams.filter((stream_name) => {
- if (!stream_data.is_stream_muted_by_name(stream_name)) {
+ const stream_id = stream_data.get_stream_id(stream_name);
+ assert(stream_id !== undefined);
+ if (!stream_data.is_muted(stream_id)) {
return true;
}
if (only_followed_topics) {
// We can use Shift + N to go to unread followed topic in muted stream.
- const stream_id = stream_data.get_stream_id(stream_name);
- assert(stream_id !== undefined);
const topics = stream_topic_history.get_recent_topic_names(stream_id);
return topics.some((topic) => user_topics.is_topic_followed(stream_id, topic));
}
@@ -83,8 +83,6 @@ export function get_next_topic(
return true;
}
// We can use N to go to next unread unmuted/followed topic in a muted stream .
- const stream_id = stream_data.get_stream_id(stream_name);
- assert(stream_id !== undefined);
const topics = stream_topic_history.get_recent_topic_names(stream_id);
return topics.some((topic) => user_topics.is_topic_unmuted_or_followed(stream_id, topic));
});
@@ -110,7 +108,7 @@ export function get_next_topic(
/* istanbul ignore next */
return topics.filter((topic) => !user_topics.is_topic_muted(stream_id, topic));
- } else if (stream_data.is_stream_muted_by_name(stream_name)) {
+ } else if (stream_data.is_muted(stream_id)) {
return topics.filter((topic) =>
user_topics.is_topic_unmuted_or_followed(stream_id, topic),
);
diff --git a/web/tests/stream_data.test.js b/web/tests/stream_data.test.js
index a6310f7c5fe..b632ac0c288 100644
--- a/web/tests/stream_data.test.js
+++ b/web/tests/stream_data.test.js
@@ -700,14 +700,6 @@ const jazy = {
is_muted: true,
};
-test("is_muted", () => {
- stream_data.add_sub(tony);
- stream_data.add_sub(jazy);
- assert.ok(!stream_data.is_stream_muted_by_name("tony"));
- assert.ok(stream_data.is_stream_muted_by_name("jazy"));
- assert.ok(stream_data.is_stream_muted_by_name("EEXISTS"));
-});
-
test("is_new_stream_announcements_stream_muted", () => {
stream_data.add_sub(tony);
stream_data.add_sub(jazy);
diff --git a/web/tests/topic_generator.test.js b/web/tests/topic_generator.test.js
index 1ce3a8e87b6..31f6bd11713 100644
--- a/web/tests/topic_generator.test.js
+++ b/web/tests/topic_generator.test.js
@@ -85,6 +85,7 @@ run_test("topics", ({override}) => {
muted: muted_stream_id,
devel: devel_stream_id,
announce: 402,
+ "test here": 200,
};
override(stream_topic_history, "get_recent_topic_names", (stream_id) => {
@@ -100,7 +101,7 @@ run_test("topics", ({override}) => {
override(stream_data, "get_stream_id", (stream_name) => stream_id_dct[stream_name]);
- override(stream_data, "is_stream_muted_by_name", (stream_name) => stream_name === "muted");
+ override(stream_data, "is_muted", (stream_id) => stream_id === muted_stream_id);
let topic_has_unreads = new Set([
"unmuted",