mirror of https://github.com/zulip/zulip.git
unread: Extract process_unread_message.
This will facilitate adding mark-as-unread events in the (hopefully near) future.
This commit is contained in:
parent
1901e980c9
commit
80edf7456c
|
@ -425,24 +425,30 @@ 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);
|
||||
}
|
||||
|
||||
if (message.type === "stream") {
|
||||
unread_topic_counter.add(message.stream_id, message.topic, message.id);
|
||||
}
|
||||
|
||||
update_message_for_mention(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 === "private") {
|
||||
unread_pm_counter.add(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) {
|
||||
if (!message.unread) {
|
||||
unread_mentions_counter.delete(message.id);
|
||||
|
|
Loading…
Reference in New Issue