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.

composebox_typeahead: Get topics_seen_for stream id instead of name.

evykassirerf190419bc974
diff --git a/web/src/composebox_typeahead.js b/web/src/composebox_typeahead.js
index ead1aeff058..1e67e58c324 100644
--- a/web/src/composebox_typeahead.js
+++ b/web/src/composebox_typeahead.js
@@ -68,8 +68,7 @@ export function update_emoji_data() {
}
}
-export function topics_seen_for(stream_name) {
- const stream_id = stream_data.get_stream_id(stream_name);
+export function topics_seen_for(stream_id) {
if (!stream_id) {
return [];
}
@@ -729,7 +728,8 @@ export function get_candidates(query) {
return false;
}
- const topic_list = topics_seen_for(stream_name);
+ const stream_id = stream_data.get_stream_id(stream_name);
+ const topic_list = topics_seen_for(stream_id);
if (should_show_custom_query(this.token, topic_list)) {
topic_list.push(this.token);
}
@@ -1017,7 +1017,8 @@ export function initialize_topic_edit_typeahead(form_field, stream_name, dropup)
return sorted;
},
source() {
- return topics_seen_for(stream_name);
+ const stream_id = stream_data.get_stream_id(stream_name);
+ return topics_seen_for(stream_id);
},
items: 5,
};
@@ -1094,8 +1095,7 @@ export function initialize({on_enter_send}) {
$("#stream_message_recipient_topic").typeahead({
source() {
- const stream_name = compose_state.stream_name();
- return topics_seen_for(stream_name);
+ return topics_seen_for(compose_state.stream_id());
},
items: 3,
fixed: true,
diff --git a/web/tests/composebox_typeahead.test.js b/web/tests/composebox_typeahead.test.js
index 5e5cd225fbc..350238c9530 100644
--- a/web/tests/composebox_typeahead.test.js
+++ b/web/tests/composebox_typeahead.test.js
@@ -407,14 +407,14 @@ test("topics_seen_for", ({override, override_rewire}) => {
assert.equal(stream_id, denmark_stream.stream_id);
});
- assert.deepEqual(ct.topics_seen_for("Denmark"), [
+ assert.deepEqual(ct.topics_seen_for(denmark_stream.stream_id), [
"With Twisted Metal",
"acceptance",
"civil fears",
]);
// Test when the stream doesn't exist (there are no topics)
- assert.deepEqual(ct.topics_seen_for("non-existing-stream"), []);
+ assert.deepEqual(ct.topics_seen_for(""), []);
});
test("content_typeahead_selected", ({override}) => {