Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

stream_list: Specify which stream is being narrowed to zoom_in.

Evy Kassirer514ac66a8611
diff --git a/web/src/stream_list.ts b/web/src/stream_list.ts
index 10a00884954..1639d3ee260 100644
--- a/web/src/stream_list.ts
+++ b/web/src/stream_list.ts
@@ -50,6 +50,7 @@ import {user_settings} from "./user_settings.ts";
let pending_stream_list_rerender = false;
let zoomed_in = false;
let update_inbox_channel_view_callback: (channel_id: number) => void;
+let show_channel_feed_callback: (stream_id: number, trigger: string) => void;
export function set_update_inbox_channel_view_callback(value: (channel_id: number) => void): void {
update_inbox_channel_view_callback = value;
@@ -155,16 +156,17 @@ export function update_streams_sidebar_for_messages(messages: Message[]): void {
}
}
-function zoom_in(): void {
- zoomed_in = true;
- const stream_id = topic_list.active_stream_id();
- assert(stream_id !== undefined);
+function zoom_in(stream_id: number): void {
+ if (narrow_state.stream_id() !== stream_id) {
+ show_channel_feed_callback(stream_id, "sidebar");
+ }
+ zoomed_in = true;
$("#direct-messages-modal").toggleClass("no-display", true);
popovers.hide_all();
pm_list.close();
zoom_in_topics(stream_id);
- topic_list.zoom_in(get_stream_li(stream_id)!);
+ topic_list.zoom_in(get_stream_li(stream_id)!, stream_id);
$("#left-sidebar").addClass("zoom-in");
$("#left-sidebar").addClass("zoom-in-topics");
$("#left-sidebar-modal").addClass("zoom-in-topics");
@@ -1280,7 +1282,9 @@ export function handle_narrow_activated(
const $stream_li = update_stream_sidebar_for_narrow(filter);
if ($stream_li && !change_hash && !is_zoomed_in() && show_more_topics) {
- zoom_in();
+ const info = get_sidebar_stream_topic_info(filter);
+ assert(info.stream_id !== undefined);
+ zoom_in(info.stream_id);
}
// Do not auto scroll when switching topics in an already expanded channel.
@@ -1303,6 +1307,7 @@ export function initialize({
update_inbox_channel_view: (channel_id: number) => void;
}): void {
update_inbox_channel_view_callback = update_inbox_channel_view;
+ show_channel_feed_callback = show_channel_feed;
restore_collapsed_sections_state();
create_initial_sidebar_rows();
@@ -1317,7 +1322,8 @@ export function initialize({
set_event_handlers({show_channel_feed});
function on_show_more_topics(e: JQuery.ClickEvent | JQuery.KeyDownEvent): void {
- zoom_in();
+ const stream_id = stream_id_for_elt($(e.target).parents("li.narrow-filter"));
+ zoom_in(stream_id);
// We define the focus behavior for the topic list search box
// outside of the `zoom_in` method, since we want the focus
// to only happen when the user clicks on the "SHOW ALL TOPICS"
diff --git a/web/src/topic_list.ts b/web/src/topic_list.ts
index 79b71c96236..682491d28ab 100644
--- a/web/src/topic_list.ts
+++ b/web/src/topic_list.ts
@@ -594,17 +594,11 @@ export function left_sidebar_scroll_zoomed_in_topic_into_view(): void {
// For zooming, we only do topic-list stuff here...let stream_list
// handle hiding/showing the non-narrowed streams
-export function zoom_in($stream_li: JQuery): void {
+export function zoom_in($stream_li: JQuery, stream_id: number): void {
previous_search_term = "";
pre_search_scroll_position = 0;
ui_util.disable_left_sidebar_search();
- const stream_id = active_stream_id();
- if (stream_id === undefined) {
- blueslip.error("Cannot find widget for topic history zooming.");
- return;
- }
-
zoomed = true;
zoomed_in_widget = new LeftSidebarTopicListWidget($stream_li, stream_id, true);
const spinner = true;
@@ -612,7 +606,7 @@ export function zoom_in($stream_li: JQuery): void {
reset_topic_list_cursor({show_highlight: false});
function on_success(): void {
- if (!active_widgets.has(stream_id!)) {
+ if (!active_widgets.has(stream_id)) {
blueslip.warn("User re-narrowed before topic history was returned.");
return;
}
@@ -626,7 +620,7 @@ export function zoom_in($stream_li: JQuery): void {
return;
}
- rebuild_left_sidebar($stream_li, stream_id!);
+ rebuild_left_sidebar($stream_li, stream_id);
// It is fine to force scroll here even if user has scrolled to a different
// position since we just added some topics to the list which moved user
// to a different position anyway.