mirror of https://github.com/zulip/zulip.git
stream_data: Remove is_stream_muted_by_name to favor stream ids.
This commit is contained in:
parent
fd5112fbb2
commit
90cced31af
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue