mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 23:43:43 +00:00
user_topics_ui: Rerender combined feed to make unmuted topics visible.
Since combined feed no longer contains a continuous history of muted messages, we need to rerender it display the newly visible messages.
This commit is contained in:
@@ -28,6 +28,7 @@ import * as message_edit from "./message_edit.ts";
|
|||||||
import * as message_events from "./message_events.js";
|
import * as message_events from "./message_events.js";
|
||||||
import * as message_lists from "./message_lists.ts";
|
import * as message_lists from "./message_lists.ts";
|
||||||
import * as message_live_update from "./message_live_update.ts";
|
import * as message_live_update from "./message_live_update.ts";
|
||||||
|
import * as message_view from "./message_view.ts";
|
||||||
import * as message_view_header from "./message_view_header.ts";
|
import * as message_view_header from "./message_view_header.ts";
|
||||||
import * as muted_users_ui from "./muted_users_ui.ts";
|
import * as muted_users_ui from "./muted_users_ui.ts";
|
||||||
import * as narrow_state from "./narrow_state.ts";
|
import * as narrow_state from "./narrow_state.ts";
|
||||||
@@ -1028,6 +1029,7 @@ export function dispatch_normal_event(event) {
|
|||||||
user_topics_ui.handle_topic_updates(
|
user_topics_ui.handle_topic_updates(
|
||||||
event,
|
event,
|
||||||
message_events.update_current_view_for_topic_visibility(),
|
message_events.update_current_view_for_topic_visibility(),
|
||||||
|
message_view.rerender_combined_feed,
|
||||||
);
|
);
|
||||||
// Discard cached message lists if `event` topic was / is followed.
|
// Discard cached message lists if `event` topic was / is followed.
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import $ from "jquery";
|
|||||||
import assert from "minimalistic-assert";
|
import assert from "minimalistic-assert";
|
||||||
|
|
||||||
import * as inbox_util from "./inbox_util.ts";
|
import * as inbox_util from "./inbox_util.ts";
|
||||||
|
import type {MessageList} from "./message_list.ts";
|
||||||
import * as message_lists from "./message_lists.ts";
|
import * as message_lists from "./message_lists.ts";
|
||||||
import type {Message} from "./message_store.ts";
|
import type {Message} from "./message_store.ts";
|
||||||
import * as narrow_state from "./narrow_state.ts";
|
import * as narrow_state from "./narrow_state.ts";
|
||||||
@@ -36,7 +37,12 @@ function should_add_topic_update_delay(visibility_policy: number): boolean {
|
|||||||
export function handle_topic_updates(
|
export function handle_topic_updates(
|
||||||
user_topic_event: ServerUserTopic,
|
user_topic_event: ServerUserTopic,
|
||||||
refreshed_current_narrow = false,
|
refreshed_current_narrow = false,
|
||||||
|
rerender_combined_feed_callback?: (combined_feed_msg_list: MessageList) => void,
|
||||||
): void {
|
): void {
|
||||||
|
const was_topic_visible_in_home = user_topics.is_topic_visible_in_home(
|
||||||
|
user_topic_event.stream_id,
|
||||||
|
user_topic_event.topic_name,
|
||||||
|
);
|
||||||
// Update the UI after changes in topic visibility policies.
|
// Update the UI after changes in topic visibility policies.
|
||||||
user_topics.set_user_topic(user_topic_event);
|
user_topics.set_user_topic(user_topic_event);
|
||||||
|
|
||||||
@@ -50,7 +56,23 @@ export function handle_topic_updates(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!refreshed_current_narrow) {
|
if (!refreshed_current_narrow) {
|
||||||
message_lists.current?.update_muting_and_rerender();
|
if (message_lists.current?.data.filter.is_in_home()) {
|
||||||
|
const is_topic_visible_in_home = user_topics.is_topic_visible_in_home(
|
||||||
|
user_topic_event.stream_id,
|
||||||
|
user_topic_event.topic_name,
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
rerender_combined_feed_callback &&
|
||||||
|
!was_topic_visible_in_home &&
|
||||||
|
is_topic_visible_in_home
|
||||||
|
) {
|
||||||
|
rerender_combined_feed_callback(message_lists.current);
|
||||||
|
} else {
|
||||||
|
message_lists.current.update_muting_and_rerender();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message_lists.current?.update_muting_and_rerender();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
should_add_topic_update_delay(user_topic_event.visibility_policy) ? 500 : 0,
|
should_add_topic_update_delay(user_topic_event.visibility_policy) ? 500 : 0,
|
||||||
@@ -83,7 +105,19 @@ export function handle_topic_updates(
|
|||||||
// Defer updates for any background-rendered messages lists until the visible one has been updated.
|
// Defer updates for any background-rendered messages lists until the visible one has been updated.
|
||||||
for (const list of message_lists.all_rendered_message_lists()) {
|
for (const list of message_lists.all_rendered_message_lists()) {
|
||||||
if (message_lists.current !== list) {
|
if (message_lists.current !== list) {
|
||||||
list.update_muting_and_rerender();
|
if (list.data.filter.is_in_home()) {
|
||||||
|
const is_topic_visible_in_home = user_topics.is_topic_visible_in_home(
|
||||||
|
user_topic_event.stream_id,
|
||||||
|
user_topic_event.topic_name,
|
||||||
|
);
|
||||||
|
if (!was_topic_visible_in_home && is_topic_visible_in_home) {
|
||||||
|
message_lists.delete_message_list(list);
|
||||||
|
} else {
|
||||||
|
list.update_muting_and_rerender();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list.update_muting_and_rerender();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user