Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
stream-settings: Refactor code used to update url hash.
Sahil Batrae26ca5a54783
diff --git a/web/src/stream_edit.js b/web/src/stream_edit.jsindex a12b2209c34..4605a8dbad3 100644--- a/web/src/stream_edit.js+++ b/web/src/stream_edit.js@@ -84,13 +84,12 @@ function get_sub_for_target(target) {return sub;}-export function open_edit_panel_for_row(stream_row, right_side_tab) {+export function open_edit_panel_for_row(stream_row) {const sub = get_sub_for_target(stream_row);$(".stream-row.active").removeClass("active");stream_settings_components.show_subs_pane.settings(sub);$(stream_row).addClass("active");- stream_edit_toggler.setup_subscriptions_stream_hash(sub, right_side_tab);setup_stream_settings(stream_row);}@@ -258,7 +257,7 @@ export function show_settings_for(node) {scroll_util.get_content_element($("#stream_settings")).html(html);$("#stream_settings .tab-container").prepend(stream_edit_toggler.toggler.get());- stream_ui_updates.update_toggler_for_sub(sub);+ stream_ui_updates.set_up_right_panel_section(sub);const $edit_container = stream_settings_containers.get_edit_container(sub);@@ -564,7 +563,7 @@ export function initialize() {stream_settings_components.sub_or_unsub(sub, $stream_row);if (!sub.subscribed) {- open_edit_panel_for_row($stream_row, stream_edit_toggler.select_tab);+ open_edit_panel_for_row($stream_row);}stream_ui_updates.update_regular_sub_settings(sub);@@ -632,7 +631,7 @@ export function initialize() {$("#streams_overlay_container").on("click", ".stream-row", function (e) {if ($(e.target).closest(".check, .subscription_settings").length === 0) {- open_edit_panel_for_row(this, stream_edit_toggler.select_tab);+ open_edit_panel_for_row(this);}});diff --git a/web/src/stream_edit_toggler.ts b/web/src/stream_edit_toggler.tsindex 304d985b2ec..62751ca9a9c 100644--- a/web/src/stream_edit_toggler.ts+++ b/web/src/stream_edit_toggler.ts@@ -10,6 +10,10 @@ import type {StreamSubscription} from "./sub_store";export let toggler: components.Toggle;export let select_tab = "personal";+export function set_select_tab(right_side_tab: string): void {+ select_tab = right_side_tab;+}+export function setup_subscriptions_stream_hash(sub: StreamSubscription,right_side_tab: string,diff --git a/web/src/stream_settings_ui.js b/web/src/stream_settings_ui.jsindex 9e33ec23157..9688a766d63 100644--- a/web/src/stream_settings_ui.js+++ b/web/src/stream_settings_ui.js@@ -689,7 +689,7 @@ export function switch_to_stream_row(stream_id, right_side_tab) {scroll_util.scroll_element_into_container($stream_row, $container);- stream_edit.open_edit_panel_for_row($stream_row, right_side_tab);+ stream_edit.open_edit_panel_for_row($stream_row);stream_edit_toggler.toggler.goto(right_side_tab);}@@ -737,6 +737,7 @@ export function change_state(section, right_side_tab) {toggler.goto("subscribed");} else {show_right_section();+ stream_edit_toggler.set_select_tab(right_side_tab);switch_to_stream_row(stream_id, right_side_tab);}return;diff --git a/web/src/stream_ui_updates.js b/web/src/stream_ui_updates.jsindex ea8018a8e9a..2246f8815cb 100644--- a/web/src/stream_ui_updates.js+++ b/web/src/stream_ui_updates.js@@ -137,10 +137,7 @@ export function initialize_cant_subscribe_popover() {initialize_disable_btn_hint_popover($button_wrapper);}-export function update_toggler_for_sub(sub) {- if (!hash_parser.is_editing_stream(sub.stream_id)) {- return;- }+export function set_up_right_panel_section(sub) {if (sub.subscribed) {stream_edit_toggler.toggler.enable_tab("personal");stream_edit_toggler.toggler.goto(stream_edit_toggler.select_tab);@@ -158,6 +155,14 @@ export function update_toggler_for_sub(sub) {enable_or_disable_subscribers_tab(sub);}+export function update_toggler_for_sub(sub) {+ if (!hash_parser.is_editing_stream(sub.stream_id)) {+ return;+ }++ set_up_right_panel_section(sub);+}+export function enable_or_disable_subscribers_tab(sub) {if (!hash_parser.is_editing_stream(sub.stream_id)) {return;