mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
streams_list: Don't zoom out user when stream list rearranges.
Fixes #23588 When a new message arrives in an inactive stream, it will lead to stream being marked as active from inactive which leads to stream list being rearranged which zooms out the user since the active stream is reset momentarily. To avoid this, we delay the stream list redraw until user zooms out and only update the topics list.
This commit is contained in:
@@ -409,6 +409,18 @@ function set_stream_unread_count(stream_id, count, stream_has_any_unread_mention
|
||||
}
|
||||
|
||||
export function update_streams_sidebar(force_rerender) {
|
||||
if (!force_rerender && topic_zoom.is_zoomed_in()) {
|
||||
// We do our best to update topics that are displayed
|
||||
// in case user zoomed in. Streams list will be updated,
|
||||
// once the user zooms out. This avoids user being zoomed out
|
||||
// when a new message causes streams to re-arrange.
|
||||
const filter = narrow_state.filter();
|
||||
update_stream_sidebar_for_narrow(filter);
|
||||
topic_zoom.set_pending_stream_list_rerender(true);
|
||||
return;
|
||||
}
|
||||
topic_zoom.set_pending_stream_list_rerender(false);
|
||||
|
||||
build_stream_list(force_rerender);
|
||||
|
||||
stream_cursor.redraw();
|
||||
|
@@ -4,6 +4,7 @@ import * as popovers from "./popovers";
|
||||
import * as stream_list from "./stream_list";
|
||||
import * as topic_list from "./topic_list";
|
||||
|
||||
let pending_stream_list_rerender = false;
|
||||
let zoomed_in = false;
|
||||
|
||||
export function is_zoomed_in() {
|
||||
@@ -22,7 +23,14 @@ function zoom_in() {
|
||||
zoomed_in = true;
|
||||
}
|
||||
|
||||
export function set_pending_stream_list_rerender(value) {
|
||||
pending_stream_list_rerender = value;
|
||||
}
|
||||
|
||||
export function zoom_out() {
|
||||
if (pending_stream_list_rerender) {
|
||||
stream_list.update_streams_sidebar(true);
|
||||
}
|
||||
const $stream_li = topic_list.get_stream_li();
|
||||
|
||||
popovers.hide_all_except_sidebars();
|
||||
|
Reference in New Issue
Block a user