diff --git a/frontend_tests/node_tests/message_store.js b/frontend_tests/node_tests/message_store.js index 06e1794094..16d587cdfc 100644 --- a/frontend_tests/node_tests/message_store.js +++ b/frontend_tests/node_tests/message_store.js @@ -233,7 +233,7 @@ test("errors", () => { "set_partner", () => assert(false), () => { - message_store.process_message_for_recent_private_messages(message); + pm_conversations.process_message(message); }, ); }); diff --git a/static/js/message_helper.js b/static/js/message_helper.js index 91dd070b0f..a339f48e36 100644 --- a/static/js/message_helper.js +++ b/static/js/message_helper.js @@ -2,6 +2,7 @@ import * as alert_words from "./alert_words"; import * as message_store from "./message_store"; import * as message_user_ids from "./message_user_ids"; import * as people from "./people"; +import * as pm_conversations from "./pm_conversations"; import * as recent_senders from "./recent_senders"; import * as stream_topic_history from "./stream_topic_history"; import * as util from "./util"; @@ -59,7 +60,7 @@ export function process_new_message(message) { message.pm_with_url = people.pm_with_url(message); message.to_user_ids = people.pm_reply_user_string(message); - message_store.process_message_for_recent_private_messages(message); + pm_conversations.process_message(message); if (people.is_my_user_id(message.sender_id)) { for (const recip of message.display_recipient) { diff --git a/static/js/message_store.js b/static/js/message_store.js index 8ea96f144b..5e9174d836 100644 --- a/static/js/message_store.js +++ b/static/js/message_store.js @@ -1,7 +1,6 @@ import * as blueslip from "./blueslip"; import * as message_list from "./message_list"; import * as people from "./people"; -import * as pm_conversations from "./pm_conversations"; const stored_messages = new Map(); @@ -69,19 +68,6 @@ export function get_pm_full_names(message) { return names.join(", "); } -export function process_message_for_recent_private_messages(message) { - const user_ids = people.pm_with_user_ids(message); - if (!user_ids) { - return; - } - - for (const user_id of user_ids) { - pm_conversations.set_partner(user_id); - } - - pm_conversations.recent.insert(user_ids, message.id); -} - export function set_message_booleans(message) { const flags = message.flags || []; diff --git a/static/js/pm_conversations.js b/static/js/pm_conversations.js index d90e1a29f2..c2e43c1992 100644 --- a/static/js/pm_conversations.js +++ b/static/js/pm_conversations.js @@ -77,6 +77,19 @@ class RecentPrivateMessages { export let recent = new RecentPrivateMessages(); +export function process_message(message) { + const user_ids = people.pm_with_user_ids(message); + if (!user_ids) { + return; + } + + for (const user_id of user_ids) { + set_partner(user_id); + } + + recent.insert(user_ids, message.id); +} + export function clear_for_testing() { recent = new RecentPrivateMessages(); partners.clear();