mirror of https://github.com/zulip/zulip.git
message_list: Move condition to render update_trailing_bookend.
We move the condition to render `update_trailing_bookend` inside the function to ensure we are only showing it when required. This also fixes a bug where we render trailing bookend when stream privacy is changed regardless of if the bookend is required.
This commit is contained in:
parent
6099364183
commit
6f0fdef80d
|
@ -373,20 +373,28 @@ export class MessageList {
|
|||
// Maintains a trailing bookend element explaining any changes in
|
||||
// your subscribed/unsubscribed status at the bottom of the
|
||||
// message list.
|
||||
update_trailing_bookend() {
|
||||
update_trailing_bookend(force_render = false) {
|
||||
this.view.clear_trailing_bookend();
|
||||
if (this.is_combined_feed_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
const stream_name = narrow_state.stream_name();
|
||||
if (stream_name === undefined) {
|
||||
// Trailing bookends are only for channel views.
|
||||
return;
|
||||
}
|
||||
|
||||
// If user narrows to a stream, don't update
|
||||
// trailing bookend if user is subscribed.
|
||||
const sub = stream_data.get_sub(stream_name);
|
||||
if (sub && sub.subscribed && !page_params.is_spectator && !force_render) {
|
||||
return;
|
||||
}
|
||||
|
||||
let deactivated = false;
|
||||
let just_unsubscribed = false;
|
||||
const subscribed = stream_data.is_subscribed_by_name(stream_name);
|
||||
const sub = stream_data.get_sub(stream_name);
|
||||
const invite_only = sub && sub.invite_only;
|
||||
const is_web_public = sub && sub.is_web_public;
|
||||
const can_toggle_subscription =
|
||||
|
|
|
@ -1049,15 +1049,7 @@ export class MessageListView {
|
|||
last_message_group.message_containers.at(-1).msg.historical;
|
||||
}
|
||||
|
||||
const stream_name = narrow_state.stream_name();
|
||||
if (stream_name !== undefined) {
|
||||
// If user narrows to a stream, doesn't update
|
||||
// trailing bookend if user is subscribed.
|
||||
const sub = stream_data.get_sub(stream_name);
|
||||
if (sub === undefined || !sub.subscribed || page_params.is_spectator) {
|
||||
list.update_trailing_bookend();
|
||||
}
|
||||
}
|
||||
list.update_trailing_bookend();
|
||||
|
||||
if (list === message_lists.current) {
|
||||
// Update the fade.
|
||||
|
|
|
@ -555,7 +555,7 @@ export function dispatch_normal_event(event) {
|
|||
);
|
||||
if (is_narrowed_to_stream) {
|
||||
assert(message_lists.current !== undefined);
|
||||
message_lists.current.update_trailing_bookend();
|
||||
message_lists.current.update_trailing_bookend(true);
|
||||
}
|
||||
stream_data.delete_sub(stream.stream_id);
|
||||
stream_settings_ui.remove_stream(stream.stream_id);
|
||||
|
|
|
@ -148,7 +148,7 @@ export function mark_subscribed(sub, subscribers, color) {
|
|||
|
||||
if (narrow_state.is_for_stream_id(sub.stream_id)) {
|
||||
assert(message_lists.current !== undefined);
|
||||
message_lists.current.update_trailing_bookend();
|
||||
message_lists.current.update_trailing_bookend(true);
|
||||
activity_ui.build_user_sidebar();
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ export function mark_unsubscribed(sub) {
|
|||
// Update UI components if we just unsubscribed from the
|
||||
// currently viewed stream.
|
||||
assert(message_lists.current !== undefined);
|
||||
message_lists.current.update_trailing_bookend();
|
||||
message_lists.current.update_trailing_bookend(true);
|
||||
|
||||
// This update would likely be better implemented by having it
|
||||
// disappear whenever no unread messages remain.
|
||||
|
|
Loading…
Reference in New Issue