js: Break cyclic dependency between topic_list and topic_list_data.

This commit breaks the cyclic dependency between "topic_list.js"
and "topic_list_data.js".

It achieves this by passing "search_term" generated by the
"get_topic_search_term" function to "topic_list_data.js" directly
through the function call from "topic_list.js".
This commit is contained in:
sbansal1999 2023-04-07 23:50:45 +05:30 committed by Tim Abbott
parent f391bfeec6
commit ea2de5b0a4
3 changed files with 7 additions and 5 deletions

View File

@ -125,7 +125,11 @@ export class TopicListWidget {
}
build_list(spinner) {
const list_info = topic_list_data.get_list_info(this.my_stream_id, zoomed);
const list_info = topic_list_data.get_list_info(
this.my_stream_id,
zoomed,
get_topic_search_term(),
);
const num_possible_topics = list_info.num_possible_topics;
const more_topics_unreads = list_info.more_topics_unreads;

View File

@ -3,7 +3,6 @@ import * as resolved_topic from "../shared/src/resolved_topic";
import * as hash_util from "./hash_util";
import * as narrow_state from "./narrow_state";
import * as stream_topic_history from "./stream_topic_history";
import * as topic_list from "./topic_list";
import * as unread from "./unread";
import * as user_topics from "./user_topics";
import * as util from "./util";
@ -11,7 +10,7 @@ import * as util from "./util";
const max_topics = 8;
const max_topics_with_unread = 12;
export function get_list_info(stream_id, zoomed) {
export function get_list_info(stream_id, zoomed, search_term) {
let topics_selected = 0;
let more_topics_unreads = 0;
let more_topics_have_unread_mention_messages = false;
@ -24,7 +23,6 @@ export function get_list_info(stream_id, zoomed) {
let topic_names = stream_topic_history.get_recent_topic_names(stream_id);
if (zoomed) {
const search_term = topic_list.get_topic_search_term();
topic_names = util.filter_by_word_prefix_match(topic_names, search_term, (item) => item);
}

View File

@ -42,7 +42,7 @@ stream_data.add_sub(general);
function get_list_info(zoomed) {
const stream_id = general.stream_id;
return topic_list_data.get_list_info(stream_id, zoomed);
return topic_list_data.get_list_info(stream_id, zoomed, topic_list.get_topic_search_term());
}
function test(label, f) {