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.

topic_generator: Fix navigating to next normal topic in muted streams.

Tim Abbott9d0375cac118
diff --git a/web/src/topic_generator.js b/web/src/topic_generator.js
index 03342908359..683c8a12dbc 100644
--- a/web/src/topic_generator.js
+++ b/web/src/topic_generator.js
@@ -1,3 +1,6 @@
+import _ from "lodash";
+
+import * as narrow_state from "./narrow_state";
import * as pm_conversations from "./pm_conversations";
import * as stream_data from "./stream_data";
import * as stream_list_sort from "./stream_list_sort";
@@ -75,16 +78,28 @@ export function get_next_topic(curr_stream, curr_topic, only_followed_topics) {
function get_unmuted_topics(stream_name) {
const stream_id = stream_data.get_stream_id(stream_name);
- let topics = stream_topic_history.get_recent_topic_names(stream_id);
+ const topics = stream_topic_history.get_recent_topic_names(stream_id);
- if (stream_data.is_stream_muted_by_name(stream_name)) {
- topics = topics.filter((topic) =>
+ if (
+ narrow_state.active() &&
+ narrow_state.stream_id() === stream_id &&
+ _.isEqual(narrow_state.filter().sorted_term_types(), ["stream", "topic"]) &&
+ !user_topics.is_topic_unmuted_or_followed(stream_id, narrow_state.topic())
+ ) {
+ // Here we're using N within a muted stream starting from
+ // a muted topic; advance to the next not-explicitly-muted
+ // unread topic in the stream, to allow using N within
+ // muted streams. We'll jump back into the normal mode if
+ // we land in a followed/unmuted topic, but that's OK.
+
+ /* 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)) {
+ return topics.filter((topic) =>
user_topics.is_topic_unmuted_or_followed(stream_id, topic),
);
- } else {
- topics = topics.filter((topic) => !user_topics.is_topic_muted(stream_id, topic));
}
- return topics;
+ return topics.filter((topic) => !user_topics.is_topic_muted(stream_id, topic));
}
function get_followed_topics(stream_name) {