mirror of https://github.com/zulip/zulip.git
filter: Fix combined feed navigating to muted unread message.
Some we didn't have a check for if topic is muted here which resulted in combined feed trying to navigate user to muted unread message if it was the first unread in the narrow.
This commit is contained in:
parent
62dfd93a83
commit
b22adc1d5f
|
@ -123,9 +123,15 @@ function message_in_home(message: Message): boolean {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (user_topics.is_topic_muted(message.stream_id, message.topic)) {
|
||||
// If topic is muted, we don't show the message.
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
// If stream is muted, we show the message if topic is unmuted or followed.
|
||||
!stream_data.is_muted(message.stream_id) ||
|
||||
user_topics.is_topic_unmuted(message.stream_id, message.topic)
|
||||
user_topics.is_topic_unmuted_or_followed(message.stream_id, message.topic)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ const $ = require("./lib/zjquery");
|
|||
const {page_params, realm} = require("./lib/zpage_params");
|
||||
|
||||
const message_store = mock_esm("../src/message_store");
|
||||
const user_topics = mock_esm("../src/user_topics");
|
||||
|
||||
const resolved_topic = zrequire("../shared/src/resolved_topic");
|
||||
const stream_data = zrequire("stream_data");
|
||||
|
@ -753,7 +754,7 @@ test("canonicalization", () => {
|
|||
assert.equal(term.operand, "link");
|
||||
});
|
||||
|
||||
test("predicate_basics", () => {
|
||||
test("predicate_basics", ({override}) => {
|
||||
// Predicates are functions that accept a message object with the message
|
||||
// attributes (not content), and return true if the message belongs in a
|
||||
// given narrow. If the narrow parameters include a search, the predicate
|
||||
|
@ -831,10 +832,33 @@ test("predicate_basics", () => {
|
|||
assert.ok(!predicate({type: stream_message, topic: "foo"}));
|
||||
|
||||
const unknown_stream_id = 999;
|
||||
override(user_topics, "is_topic_muted", () => false);
|
||||
override(user_topics, "is_topic_unmuted_or_followed", () => false);
|
||||
predicate = get_predicate([["in", "home"]]);
|
||||
assert.ok(!predicate({stream_id: unknown_stream_id, stream: "unknown"}));
|
||||
assert.ok(predicate({type: direct_message}));
|
||||
|
||||
// Muted topic is not part of in-home.
|
||||
with_overrides(({override}) => {
|
||||
override(user_topics, "is_topic_muted", () => true);
|
||||
assert.ok(!predicate({stream_id, topic: "bar"}));
|
||||
});
|
||||
|
||||
// Muted stream is not part of in-home.
|
||||
const muted_stream = {
|
||||
stream_id: 94924,
|
||||
name: "muted",
|
||||
is_muted: true,
|
||||
};
|
||||
stream_data.add_sub(muted_stream);
|
||||
assert.ok(!predicate({stream_id: muted_stream.stream_id, topic: "bar"}));
|
||||
|
||||
// Muted stream but topic is unmuted or followed is part of in-home.
|
||||
with_overrides(({override}) => {
|
||||
override(user_topics, "is_topic_unmuted_or_followed", () => true);
|
||||
assert.ok(predicate({stream_id: muted_stream.stream_id, topic: "bar"}));
|
||||
});
|
||||
|
||||
make_sub("kiosk", 1234);
|
||||
with_overrides(({override}) => {
|
||||
override(page_params, "narrow_stream", "kiosk");
|
||||
|
|
Loading…
Reference in New Issue