From 3c5adeee8af3b080aadec2630f356894dfaabe2c Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Fri, 22 May 2020 20:41:19 +0530 Subject: [PATCH] recent_topics: Update unread count of topics inplace. --- static/js/recent_topics.js | 5 +++++ static/js/unread_ops.js | 1 + 2 files changed, 6 insertions(+) diff --git a/static/js/recent_topics.js b/static/js/recent_topics.js index 3bdfcb8af7..6985ac2f4c 100644 --- a/static/js/recent_topics.js +++ b/static/js/recent_topics.js @@ -152,6 +152,11 @@ exports.update_topic_is_muted = function (stream_id, topic, is_muted) { return true; }; +exports.update_topic_unread_count = function (message) { + const topic_key = message.stream_id + ":" + message.topic; + exports.inplace_rerender(topic_key); +}; + exports.complete_rerender = function () { // NOTE: This function is grows expensive with // number of topics. Only call when necessary. diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js index c2aaf54191..28575ac514 100644 --- a/static/js/unread_ops.js +++ b/static/js/unread_ops.js @@ -15,6 +15,7 @@ function process_newly_read_message(message, options) { message_list.narrowed.show_message_as_read(message, options); } notifications.close_notification(message); + recent_topics.update_topic_unread_count(message); } exports.process_read_messages_event = function (message_ids) {