mirror of https://github.com/zulip/zulip.git
unread: Fix logic for wildcard mentions in direct messages.
Wildcard mentions in direct messages were not being count as mentions due to incorrect calculation of `is_unmuted_mention` variable in `update_message_for_mention()` function in `unread.js`. Fixed this by correcting the calculation of `is_unmuted_mention`.
This commit is contained in:
parent
f7b633f511
commit
71b915e09d
|
@ -709,10 +709,17 @@ export function update_message_for_mention(message, content_edited = false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A message is said to have an unmuted mention if message contains a mention and
|
||||||
|
// if the message is a direct message or
|
||||||
|
// if the message is in a non muted topic in an unmuted stream or
|
||||||
|
// if the message is in a followed or an unmuted topic in a muted stream.
|
||||||
const is_unmuted_mention =
|
const is_unmuted_mention =
|
||||||
message.type === "stream" &&
|
|
||||||
message.mentioned &&
|
message.mentioned &&
|
||||||
!user_topics.is_topic_muted(message.stream_id, message.topic);
|
(message.type === "private" ||
|
||||||
|
(!stream_data.is_muted(message.stream_id) &&
|
||||||
|
!user_topics.is_topic_muted(message.stream_id, message.topic)) ||
|
||||||
|
(stream_data.is_muted(message.stream_id) &&
|
||||||
|
user_topics.is_topic_unmuted_or_followed(message.stream_id, message.topic)));
|
||||||
|
|
||||||
if (is_unmuted_mention || message.mentioned_me_directly) {
|
if (is_unmuted_mention || message.mentioned_me_directly) {
|
||||||
unread_mentions_counter.add(message.id);
|
unread_mentions_counter.add(message.id);
|
||||||
|
|
|
@ -472,14 +472,32 @@ test("mentions", () => {
|
||||||
assert.deepEqual(unread.get_msg_ids_for_mentions(), []);
|
assert.deepEqual(unread.get_msg_ids_for_mentions(), []);
|
||||||
test_notifiable_count(counts.home_unread_messages, 0);
|
test_notifiable_count(counts.home_unread_messages, 0);
|
||||||
|
|
||||||
const muted_stream_id = 401;
|
const muted_stream_id = 900;
|
||||||
|
const unmuted_stream_id = 901;
|
||||||
|
|
||||||
user_topics.update_user_topics(401, "lunch", user_topics.all_visibility_policies.MUTED);
|
sub_store.add_hydrated_sub(muted_stream_id, {
|
||||||
|
muted_stream_id,
|
||||||
|
name: "muted stream for testing unread mentions",
|
||||||
|
subscribed: true,
|
||||||
|
is_muted: true,
|
||||||
|
});
|
||||||
|
sub_store.add_hydrated_sub(unmuted_stream_id, {
|
||||||
|
unmuted_stream_id,
|
||||||
|
name: "unmuted stream for testing unread mention",
|
||||||
|
subscribed: true,
|
||||||
|
is_muted: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
user_topics.update_user_topics(
|
||||||
|
muted_stream_id,
|
||||||
|
"lunch",
|
||||||
|
user_topics.all_visibility_policies.MUTED,
|
||||||
|
);
|
||||||
|
|
||||||
const already_read_message = {
|
const already_read_message = {
|
||||||
id: 14,
|
id: 14,
|
||||||
type: "stream",
|
type: "stream",
|
||||||
stream_id: 400,
|
stream_id: unmuted_stream_id,
|
||||||
topic: "lunch",
|
topic: "lunch",
|
||||||
mentioned: true,
|
mentioned: true,
|
||||||
mentioned_me_directly: true,
|
mentioned_me_directly: true,
|
||||||
|
@ -489,7 +507,7 @@ test("mentions", () => {
|
||||||
const mention_me_message = {
|
const mention_me_message = {
|
||||||
id: 15,
|
id: 15,
|
||||||
type: "stream",
|
type: "stream",
|
||||||
stream_id: 400,
|
stream_id: unmuted_stream_id,
|
||||||
topic: "lunch",
|
topic: "lunch",
|
||||||
mentioned: true,
|
mentioned: true,
|
||||||
mentioned_me_directly: true,
|
mentioned_me_directly: true,
|
||||||
|
@ -499,7 +517,7 @@ test("mentions", () => {
|
||||||
const mention_all_message = {
|
const mention_all_message = {
|
||||||
id: 16,
|
id: 16,
|
||||||
type: "stream",
|
type: "stream",
|
||||||
stream_id: 400,
|
stream_id: unmuted_stream_id,
|
||||||
topic: "lunch",
|
topic: "lunch",
|
||||||
mentioned: true,
|
mentioned: true,
|
||||||
mentioned_me_directly: false,
|
mentioned_me_directly: false,
|
||||||
|
@ -577,8 +595,10 @@ test("mentions", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("mention updates", () => {
|
test("mention updates", () => {
|
||||||
|
// Unread message in an unmuted stream.
|
||||||
const message = {
|
const message = {
|
||||||
id: 17,
|
id: 17,
|
||||||
|
stream_id: 901,
|
||||||
unread: false,
|
unread: false,
|
||||||
type: "stream",
|
type: "stream",
|
||||||
topic: "hello",
|
topic: "hello",
|
||||||
|
|
Loading…
Reference in New Issue