Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
unread: Extract process_unread_message.
Steve Howell80edf7456c69
diff --git a/static/js/unread.js b/static/js/unread.jsindex 5115ac129a2..0469d661157 100644--- a/static/js/unread.js+++ b/static/js/unread.js@@ -425,22 +425,28 @@ export function update_unread_topics(msg, event) {export function process_loaded_messages(messages) {for (const message of messages) {- if (!message.unread) {- continue;+ if (message.unread) {+ process_unread_message(message);}+ }+}- unread_messages.add(message.id);-- if (message.type === "private") {- unread_pm_counter.add(message);- }+function process_unread_message(message) {+ // The `message` here just needs to require certain fields. For example,+ // the "message" may actually be constructed from a Zulip event that doesn't+ // include fields like "content". The caller must verify that the message+ // is actually unread--we don't defend against that.+ unread_messages.add(message.id);- if (message.type === "stream") {- unread_topic_counter.add(message.stream_id, message.topic, message.id);- }+ if (message.type === "private") {+ unread_pm_counter.add(message);+ }- update_message_for_mention(message);+ if (message.type === "stream") {+ unread_topic_counter.add(message.stream_id, message.topic, message.id);}++ update_message_for_mention(message);}export function update_message_for_mention(message) {