Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

unread: Improve live update for direct mentions in muted topics.

Hardik Dharmani8c6f9b3f9591
diff --git a/web/src/unread_ops.js b/web/src/unread_ops.js
index 49edbc1e0f7..df11211065c 100644
--- a/web/src/unread_ops.js
+++ b/web/src/unread_ops.js
@@ -300,7 +300,7 @@ export function process_read_messages_event(message_ids) {
}
export function process_unread_messages_event({message_ids, message_details}) {
- // This is the reverse of process_unread_messages_event.
+ // This is the reverse of process_read_messages_event.
message_ids = unread.get_read_message_ids(message_ids);
if (message_ids.length === 0) {
return;
@@ -312,13 +312,34 @@ export function process_unread_messages_event({message_ids, message_details}) {
for (const message_id of message_ids) {
const message = message_store.get(message_id);
+ const message_info = message_details[message_id];
+ let mentioned_me_directly;
if (message) {
message.unread = true;
+ mentioned_me_directly = message.mentioned_me_directly;
+ } else {
+ // BUG: If we don't have a copy of the message locally, we
+ // have no way to correctly compute whether the mentions
+ // are personal mentions or wildcard mentions, because
+ // message_info doesn't contain that information... so we
+ // guess that it's a personal mention.
+ //
+ // This is a correctness bug, but is likely very rare: We
+ // will have a copy of all unread messages locally once
+ // the app has finished the message_fetch backfill
+ // sequence (and also will certainly have this message if
+ // this is the client where the "Mark as unread" action
+ // was taken). Further, the distinction is only important
+ // for mentions in muted streams, where we count direct
+ // mentions as important enough to promote, and wildcard
+ // mentions as not.
+ //
+ // A possible fix would be to just fetch the fully message
+ // from the API here, but the right fix likely requires API changes.
+ mentioned_me_directly = message_info.mentioned;
}
- const message_info = message_details[message_id];
-
let user_ids_string;
if (message_info.type === "private") {
@@ -328,6 +349,7 @@ export function process_unread_messages_event({message_ids, message_details}) {
unread.process_unread_message({
id: message_id,
mentioned: message_info.mentioned,
+ mentioned_me_directly,
stream_id: message_info.stream_id,
topic: message_info.topic,
type: message_info.type,