mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 16:43:57 +00:00
message lists: Don't allow user/topic mute message filtering independently.
This basically reverts4bd7ec7c36and3a9dfc02e6. The plan earlier was to have compeletely different codepaths for user and topic muting, so that we could call seperate functions in the message list class on receiving the respective events. However, this cannot be done, because if we, for example, on receiving a `muted_users` event, filter `_all_items` based on just user mutes, and store the result in `_items`, then, that result may still contain topic-muted messages, which is undesirable. Hence whenever we filter messages, we must do so based on both user as well as topic muting. (The code for the former will be added in further commits.) So, we will have a single function which will handle updating the message lists for muting.
This commit is contained in:
committed by
Tim Abbott
parent
2fc87ec644
commit
e64e5936ce
@@ -73,7 +73,7 @@ run_test("basics", () => {
|
|||||||
mld.remove([50]);
|
mld.remove([50]);
|
||||||
assert_contents(mld, [10, 15, 20, 25, 30, 35, 40, 45, 60, 70]);
|
assert_contents(mld, [10, 15, 20, 25, 30, 35, 40, 45, 60, 70]);
|
||||||
|
|
||||||
mld.update_items_for_topic_muting();
|
mld.update_items_for_muting();
|
||||||
assert_contents(mld, [10, 15, 20, 25, 30, 35, 40, 45, 60, 70]);
|
assert_contents(mld, [10, 15, 20, 25, 30, 35, 40, 45, 60, 70]);
|
||||||
|
|
||||||
mld.reset_select_to_closest();
|
mld.reset_select_to_closest();
|
||||||
|
|||||||
@@ -411,18 +411,18 @@ export function update_messages(events) {
|
|||||||
// propagated edits to be updated (since the topic edits can have
|
// propagated edits to be updated (since the topic edits can have
|
||||||
// changed the correct grouping of messages).
|
// changed the correct grouping of messages).
|
||||||
if (topic_edited || stream_changed) {
|
if (topic_edited || stream_changed) {
|
||||||
message_lists.home.update_topic_muting_and_rerender();
|
message_lists.home.update_muting_and_rerender();
|
||||||
// However, we don't need to rerender message_list.narrowed if
|
// However, we don't need to rerender message_list.narrowed if
|
||||||
// we just changed the narrow earlier in this function.
|
// we just changed the narrow earlier in this function.
|
||||||
//
|
//
|
||||||
// TODO: We can potentially optimize this logic to avoid
|
// TODO: We can potentially optimize this logic to avoid
|
||||||
// calling `update_topic_muting_and_rerender` if the muted
|
// calling `update_muting_and_rerender` if the muted
|
||||||
// messages would not match the view before or after this
|
// messages would not match the view before or after this
|
||||||
// edit. Doing so could save significant work, since most
|
// edit. Doing so could save significant work, since most
|
||||||
// topic edits will not match the current topic narrow in
|
// topic edits will not match the current topic narrow in
|
||||||
// large organizations.
|
// large organizations.
|
||||||
if (!changed_narrow && message_lists.current === message_list.narrowed) {
|
if (!changed_narrow && message_lists.current === message_list.narrowed) {
|
||||||
message_list.narrowed.update_topic_muting_and_rerender();
|
message_list.narrowed.update_muting_and_rerender();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the content of the message was edited, we do a special animation.
|
// If the content of the message was edited, we do a special animation.
|
||||||
|
|||||||
@@ -383,8 +383,8 @@ export class MessageList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_topic_muting_and_rerender() {
|
update_muting_and_rerender() {
|
||||||
this.data.update_items_for_topic_muting();
|
this.data.update_items_for_muting();
|
||||||
// We need to rerender whether or not the narrow hides muted
|
// We need to rerender whether or not the narrow hides muted
|
||||||
// topics, because we need to update recipient bars for topics
|
// topics, because we need to update recipient bars for topics
|
||||||
// we've muted when we are displaying those topics.
|
// we've muted when we are displaying those topics.
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ export class MessageListData {
|
|||||||
return this.messages_filtered_for_topic_mutes(messages);
|
return this.messages_filtered_for_topic_mutes(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_items_for_topic_muting() {
|
update_items_for_muting() {
|
||||||
if (!this.excludes_muted_topics) {
|
if (!this.excludes_muted_topics) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ import * as unread_ui from "./unread_ui";
|
|||||||
|
|
||||||
export function rerender_for_muted_topic(old_muted_topics) {
|
export function rerender_for_muted_topic(old_muted_topics) {
|
||||||
stream_list.update_streams_sidebar();
|
stream_list.update_streams_sidebar();
|
||||||
message_lists.current.update_topic_muting_and_rerender();
|
message_lists.current.update_muting_and_rerender();
|
||||||
if (message_lists.current !== message_lists.home) {
|
if (message_lists.current !== message_lists.home) {
|
||||||
message_lists.home.update_topic_muting_and_rerender();
|
message_lists.home.update_muting_and_rerender();
|
||||||
}
|
}
|
||||||
if (overlays.settings_open() && settings_muted_topics.loaded) {
|
if (overlays.settings_open() && settings_muted_topics.loaded) {
|
||||||
settings_muted_topics.populate_list();
|
settings_muted_topics.populate_list();
|
||||||
|
|||||||
Reference in New Issue
Block a user