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.

message_util: Rename "get_messages_in_topic".

bedo465a0ef0d01a
diff --git a/web/src/message_events.ts b/web/src/message_events.ts
index 520d0b2a147..782c5e2480f 100644
--- a/web/src/message_events.ts
+++ b/web/src/message_events.ts
@@ -628,7 +628,7 @@ export function update_messages(events: UpdateMessageEvent[]): void {
// Remove the stream_topic_entry for the old topics;
// must be called after we call set message topic since
- // it calls `get_messages_in_topic` which thinks that
+ // it calls `get_loaded_messages_in_topic` which thinks that
// `topic` and `stream` of the messages are correctly set.
const num_messages = event_messages.length;
if (num_messages > 0) {
diff --git a/web/src/message_util.ts b/web/src/message_util.ts
index 2150394e7ab..c6ad2b33f2a 100644
--- a/web/src/message_util.ts
+++ b/web/src/message_util.ts
@@ -29,11 +29,11 @@ export function get_count_of_messages_in_topic_sent_after_current_message(
topic: string,
message_id: number,
): number {
- const all_messages = get_messages_in_topic(stream_id, topic);
+ const all_messages = get_loaded_messages_in_topic(stream_id, topic);
return all_messages.filter((msg) => msg.id >= message_id).length;
}
-export function get_messages_in_topic(stream_id: number, topic: string): Message[] {
+export function get_loaded_messages_in_topic(stream_id: number, topic: string): Message[] {
return all_messages_data
.all_messages()
.filter(
diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.ts
index e809af37718..72fb95da788 100644
--- a/web/src/recent_view_ui.ts
+++ b/web/src/recent_view_ui.ts
@@ -808,11 +808,11 @@ export function process_topic_edit(
// logic behind this and important notes on use of this function.
recent_view_data.conversations.delete(recent_view_util.get_topic_key(old_stream_id, old_topic));
- const old_topic_msgs = message_util.get_messages_in_topic(old_stream_id, old_topic);
+ const old_topic_msgs = message_util.get_loaded_messages_in_topic(old_stream_id, old_topic);
process_messages(old_topic_msgs);
new_stream_id = new_stream_id || old_stream_id;
- const new_topic_msgs = message_util.get_messages_in_topic(new_stream_id, new_topic);
+ const new_topic_msgs = message_util.get_loaded_messages_in_topic(new_stream_id, new_topic);
process_messages(new_topic_msgs);
}
@@ -834,7 +834,7 @@ export function update_topics_of_deleted_message_ids(message_ids: number[]): voi
const msgs_to_process = [];
for (const [stream_id, topic] of topics_to_rerender.values()) {
recent_view_data.conversations.delete(recent_view_util.get_topic_key(stream_id, topic));
- const msgs = message_util.get_messages_in_topic(stream_id, topic);
+ const msgs = message_util.get_loaded_messages_in_topic(stream_id, topic);
msgs_to_process.push(...msgs);
}
diff --git a/web/src/stream_popover.ts b/web/src/stream_popover.ts
index 4a758f883e7..3174ea8d8b5 100644
--- a/web/src/stream_popover.ts
+++ b/web/src/stream_popover.ts
@@ -528,7 +528,7 @@ export async function build_move_topic_to_stream_popover(
return;
}
- const locally_cached_conversation_messages = message_util.get_messages_in_topic(
+ const locally_cached_conversation_messages = message_util.get_loaded_messages_in_topic(
current_stream_id,
topic_name,
);
@@ -837,7 +837,7 @@ export async function build_move_topic_to_stream_popover(
message_id,
);
}
- return message_util.get_messages_in_topic(current_stream_id, topic_name).length;
+ return message_util.get_loaded_messages_in_topic(current_stream_id, topic_name).length;
}
function update_move_messages_count_text(selected_option: string, message_id?: number): void {
diff --git a/web/src/stream_topic_history.ts b/web/src/stream_topic_history.ts
index dc84bc38def..e9d384e2be5 100644
--- a/web/src/stream_topic_history.ts
+++ b/web/src/stream_topic_history.ts
@@ -305,7 +305,7 @@ export function remove_messages(opts: {
// Update max_message_id in topic
if (existing_topic.message_id <= max_removed_msg_id) {
- const msgs_in_topic = message_util.get_messages_in_topic(stream_id, topic_name);
+ const msgs_in_topic = message_util.get_loaded_messages_in_topic(stream_id, topic_name);
let max_message_id = 0;
for (const msg of msgs_in_topic) {
if (msg.id > max_message_id) {
diff --git a/web/tests/stream_topic_history.test.cjs b/web/tests/stream_topic_history.test.cjs
index 71fc2735a0d..aca6bc765cd 100644
--- a/web/tests/stream_topic_history.test.cjs
+++ b/web/tests/stream_topic_history.test.cjs
@@ -76,7 +76,7 @@ test("basics", () => {
assert.deepEqual(history, ["Topic1", "topic2"]);
assert.deepEqual(max_message_id, 104);
- message_util.get_messages_in_topic = () => [{id: 101}, {id: 102}];
+ message_util.get_loaded_messages_in_topic = () => [{id: 101}, {id: 102}];
message_util.get_max_message_id_in_stream = () => 103;
// Removing the last msg in topic1 changes the order
stream_topic_history.remove_messages({
@@ -91,7 +91,7 @@ test("basics", () => {
max_message_id = stream_topic_history.get_max_message_id(stream_id);
assert.deepEqual(max_message_id, 103);
- delete message_util.get_messages_in_topic;
+ delete message_util.get_loaded_messages_in_topic;
// Removing first topic1 message has no effect.
stream_topic_history.remove_messages({
stream_id,