mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
stream-settings: Refactor code used to update url hash.
This commit refactors code to not try to update the hash multiple times. We now update the url hash only in the callback function for toggler.goto and remove the call to setup_subscriptions_stream_hash in open_edit_panel_for_row. This change works as the hash depends on the section being opened in right panel, so it seems better to handle the hash update while toggling to the correct section. A couple of more changes we need to do to make this work correctly are - - We extract the code to call "toggler.goto" for the correct section outside the update_toggler_for_sub to a new function set_up_right_panel_section. This is changed as update_toggler_for_sub returns early without doing anything if the url hash is not the one we have when settings panel for a particular stream is opened and now the hash is updated after that check as a callback from toggler.goto. - set_up_right_panel_section uses stream_edit_toggler.select_tab to toggle to the correct section in right panel so we now need to set stream_edit_toggler.select_tab in change_state.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user