diff --git a/frontend_tests/node_tests/recent_senders.js b/frontend_tests/node_tests/recent_senders.js index 4f745205b0..dd6933689d 100644 --- a/frontend_tests/node_tests/recent_senders.js +++ b/frontend_tests/node_tests/recent_senders.js @@ -28,12 +28,14 @@ run_test("process_message_for_senders", () => { // New stream const message1 = { + type: "stream", stream_id: stream1, id: (next_id += 1), topic: topic1, sender_id: sender1, }; const message2 = { + type: "stream", stream_id: stream2, id: (next_id += 1), topic: topic1, @@ -62,6 +64,7 @@ run_test("process_message_for_senders", () => { // New topic const message3 = { + type: "stream", stream_id: stream1, id: (next_id += 1), topic: topic2, @@ -77,6 +80,7 @@ run_test("process_message_for_senders", () => { // New sender const message4 = { + type: "stream", stream_id: stream1, id: (next_id += 1), topic: topic1, @@ -92,6 +96,7 @@ run_test("process_message_for_senders", () => { // More recent message const message5 = { + type: "stream", stream_id: stream1, id: (next_id += 1), topic: topic1, @@ -107,18 +112,21 @@ run_test("process_message_for_senders", () => { // Same stream, but different topics const message6 = { + type: "stream", stream_id: stream3, id: (next_id += 1), topic: topic1, sender_id: sender1, }; const message7 = { + type: "stream", stream_id: stream3, id: (next_id += 1), topic: topic2, sender_id: sender2, }; const message8 = { + type: "stream", stream_id: stream3, id: (next_id += 1), topic: topic3, @@ -144,6 +152,7 @@ run_test("process_message_for_senders", () => { // new message in topic2 const message9 = { + type: "stream", stream_id: stream3, id: (next_id += 1), topic: topic2, diff --git a/static/js/recent_senders.js b/static/js/recent_senders.js index f55e794044..b450fc1e40 100644 --- a/static/js/recent_senders.js +++ b/static/js/recent_senders.js @@ -76,9 +76,11 @@ exports.update_topics_of_message_ids = function (message_ids) { for (const msg_id of message_ids) { // Note: message_store retians data of msg post deletion. const message = message_store.get(msg_id); - // Create unique keys for stream_id and topic. - const topic_key = message.stream_id + ":" + message.topic; - topics_to_update.set(topic_key, [message.stream_id, message.topic]); + if (message.type === "stream") { + // Create unique keys for stream_id and topic. + const topic_key = message.stream_id + ":" + message.topic; + topics_to_update.set(topic_key, [message.stream_id, message.topic]); + } } for (const [stream_id, topic] of topics_to_update.values()) { diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js index 9bda62c7d5..322e68a76f 100644 --- a/static/js/recent_topics.js +++ b/static/js/recent_topics.js @@ -242,8 +242,10 @@ exports.update_topics_of_message_ids = function (message_ids) { const topics_to_rerender = new Map(); for (const msg_id of message_ids) { const message = message_store.get(msg_id); - const topic_key = get_topic_key(message.stream_id, message.topic); - topics_to_rerender.set(topic_key, [message.stream_id, message.topic]); + if (message.type === "stream") { + const topic_key = get_topic_key(message.stream_id, message.topic); + topics_to_rerender.set(topic_key, [message.stream_id, message.topic]); + } } for (const [stream_id, topic] of topics_to_rerender.values()) {