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.

narrow: Narrow to new/empty topics with Ctrl + . shortcut.

Tim Abbotta5a958d18a65
diff --git a/frontend_tests/node_tests/narrow.js b/frontend_tests/node_tests/narrow.js
index fb58c83e9cc..d16017d9e8b 100644
--- a/frontend_tests/node_tests/narrow.js
+++ b/frontend_tests/node_tests/narrow.js
@@ -2,13 +2,11 @@
const {strict: assert} = require("assert");
-const {mock_esm, with_field, zrequire} = require("../zjsunit/namespace");
+const {with_field, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery");
const {page_params} = require("../zjsunit/zpage_params");
-const stream_topic_history = mock_esm("../../static/js/stream_topic_history");
-
const hash_util = zrequire("hash_util");
const compose_state = zrequire("compose_state");
const narrow_banner = zrequire("narrow_banner");
@@ -369,7 +367,6 @@ run_test("narrow_to_compose_target streams", ({override}) => {
compose_state.set_message_type("stream");
stream_data.add_sub({name: "ROME", stream_id: 99});
compose_state.stream_name("ROME");
- override(stream_topic_history, "get_recent_topic_names", () => ["one", "two", "three"]);
// Test with existing topic
compose_state.topic("one");
@@ -387,7 +384,10 @@ run_test("narrow_to_compose_target streams", ({override}) => {
args.called = false;
narrow.to_compose_target();
assert.equal(args.called, true);
- assert.deepEqual(args.operators, [{operator: "stream", operand: "ROME"}]);
+ assert.deepEqual(args.operators, [
+ {operator: "stream", operand: "ROME"},
+ {operator: "topic", operand: "four"},
+ ]);
// Test with blank topic
compose_state.topic("");
diff --git a/static/js/narrow.js b/static/js/narrow.js
index 3484d1f6038..7ed71bffbc6 100644
--- a/static/js/narrow.js
+++ b/static/js/narrow.js
@@ -772,10 +772,9 @@ export function to_compose_target() {
}
// If we are composing to a new topic, we narrow to the stream but
// grey-out the message view instead of narrowing to an empty view.
- const topics = stream_topic_history.get_recent_topic_names(stream_id);
const operators = [{operator: "stream", operand: stream_name}];
const topic = compose_state.topic();
- if (topics.includes(topic)) {
+ if (topic !== "") {
operators.push({operator: "topic", operand: topic});
}
activate(operators, opts);