Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
recent_senders: Return senders in most recent sender first order.
Aman Agrawalc0ad0b3b1007
diff --git a/frontend_tests/node_tests/recent_senders.js b/frontend_tests/node_tests/recent_senders.jsindex b72fdfdcf7b..af9f88f8f53 100644--- a/frontend_tests/node_tests/recent_senders.js+++ b/frontend_tests/node_tests/recent_senders.js@@ -227,7 +227,7 @@ test("process_stream_message", () => {// Test topic changeassert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "3");- assert.equal(rs.get_topic_recent_senders(stream3, topic2).toString(), "2,3");+ assert.equal(rs.get_topic_recent_senders(stream3, topic2).toString(), "3,2");// message7's topic was changed by usermessage7.topic = topic3;@@ -240,11 +240,11 @@ test("process_stream_message", () => {new_topic: topic3,});- assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3");+ assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "3,2");assert.equal(rs.get_topic_recent_senders(stream3, topic2).toString(), "3");// Test stream change- assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "2,3");+ assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "3,2");assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "");message7.stream_id = stream4;@@ -258,10 +258,10 @@ test("process_stream_message", () => {});assert.equal(rs.get_topic_recent_senders(stream3, topic3).toString(), "");- assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3");+ assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "3,2");// Test stream & topic change- assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "2,3");+ assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "3,2");assert.equal(rs.get_topic_recent_senders(stream5, topic4).toString(), "");message7.stream_id = stream5;@@ -279,8 +279,8 @@ test("process_stream_message", () => {});assert.equal(rs.get_topic_recent_senders(stream4, topic3).toString(), "");- assert.equal(rs.get_topic_recent_senders(stream5, topic4).toString(), "2,3");- assert.equal(rs.get_topic_recent_senders(stream1, topic1).toString(), "2,1");+ assert.equal(rs.get_topic_recent_senders(stream5, topic4).toString(), "3,2");+ assert.equal(rs.get_topic_recent_senders(stream1, topic1).toString(), "1,2");// delete message1 and message5 sent by sender1rs.update_topics_of_deleted_message_ids([message1.id, message5.id]);diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.jsindex 67787cd12bd..f32fae6bd8d 100644--- a/frontend_tests/node_tests/recent_topics.js+++ b/frontend_tests/node_tests/recent_topics.js@@ -112,7 +112,7 @@ mock_esm("../../static/js/pm_list", {handle_narrow_deactivated: noop,});mock_esm("../../static/js/recent_senders", {- get_topic_recent_senders: () => [1, 2],+ get_topic_recent_senders: () => [2, 1],});mock_esm("../../static/js/stream_data", {is_muted: () =>diff --git a/static/js/recent_senders.js b/static/js/recent_senders.jsindex ca09d4300d3..35e7ba77008 100644--- a/static/js/recent_senders.js+++ b/static/js/recent_senders.js@@ -201,7 +201,7 @@ export function get_topic_recent_senders(stream_id, topic) {function by_max_message_id(item1, item2) {const list1 = item1[1];const list2 = item2[1];- return list1.max_id() - list2.max_id();+ return list2.max_id() - list1.max_id();}const sorted_senders = Array.from(sender_dict.entries()).sort(by_max_message_id);diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.jsindex d476e30aadc..9fc536f3e92 100644--- a/static/js/recent_topics_ui.js+++ b/static/js/recent_topics_ui.js@@ -400,8 +400,12 @@ function format_conversation(conversation_data) {context.topic,);- // Display in most recent sender first order- all_senders = recent_senders.get_topic_recent_senders(context.stream_id, context.topic);+ // Since the css for displaying senders in reverse order is much simpler,+ // we provide our handlebars with senders in opposite order.+ // Display in most recent sender first order.+ all_senders = recent_senders+ .get_topic_recent_senders(context.stream_id, context.topic)+ .reverse();senders = all_senders.slice(-MAX_AVATAR);// Collect extra sender fullname for tooltip