mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
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:
@@ -125,7 +125,11 @@ export class TopicListWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
build_list(spinner) {
|
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 num_possible_topics = list_info.num_possible_topics;
|
||||||
const more_topics_unreads = list_info.more_topics_unreads;
|
const more_topics_unreads = list_info.more_topics_unreads;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import * as resolved_topic from "../shared/src/resolved_topic";
|
|||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as stream_topic_history from "./stream_topic_history";
|
import * as stream_topic_history from "./stream_topic_history";
|
||||||
import * as topic_list from "./topic_list";
|
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
import * as user_topics from "./user_topics";
|
import * as user_topics from "./user_topics";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
@@ -11,7 +10,7 @@ import * as util from "./util";
|
|||||||
const max_topics = 8;
|
const max_topics = 8;
|
||||||
const max_topics_with_unread = 12;
|
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 topics_selected = 0;
|
||||||
let more_topics_unreads = 0;
|
let more_topics_unreads = 0;
|
||||||
let more_topics_have_unread_mention_messages = false;
|
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);
|
let topic_names = stream_topic_history.get_recent_topic_names(stream_id);
|
||||||
if (zoomed) {
|
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);
|
topic_names = util.filter_by_word_prefix_match(topic_names, search_term, (item) => item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ stream_data.add_sub(general);
|
|||||||
|
|
||||||
function get_list_info(zoomed) {
|
function get_list_info(zoomed) {
|
||||||
const stream_id = general.stream_id;
|
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) {
|
function test(label, f) {
|
||||||
|
|||||||
Reference in New Issue
Block a user