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_settings: Show relevant streams in left panel.

tnmkr25cca93bc913
diff --git a/web/src/hashchange.js b/web/src/hashchange.js
index 4e2811437f7..468dc6fc935 100644
--- a/web/src/hashchange.js
+++ b/web/src/hashchange.js
@@ -278,7 +278,7 @@ function do_hashchange_overlay(old_hash) {
if (base === "streams") {
// e.g. #streams/29/social/subscribers
const right_side_tab = hash_parser.get_current_nth_hash_section(3);
- stream_settings_ui.change_state(section, right_side_tab);
+ stream_settings_ui.change_state(section, undefined, right_side_tab);
return;
}
@@ -346,7 +346,17 @@ function do_hashchange_overlay(old_hash) {
if (base === "streams") {
// e.g. #streams/29/social/subscribers
const right_side_tab = hash_parser.get_current_nth_hash_section(3);
- stream_settings_ui.launch(section, right_side_tab);
+
+ if (is_somebody_else_profile_open()) {
+ stream_settings_ui.launch(section, "all-streams", right_side_tab);
+ return;
+ }
+
+ // We pass left_side_tab as undefined in change_state to
+ // select the tab based on user's subscriptions. "Subscribed" is
+ // selected if user is subscribed to the stream being edited.
+ // Otherwise "All streams" is selected.
+ stream_settings_ui.launch(section, undefined, right_side_tab);
return;
}
diff --git a/web/src/stream_settings_ui.js b/web/src/stream_settings_ui.js
index d6c718693ed..30afaa5c8d4 100644
--- a/web/src/stream_settings_ui.js
+++ b/web/src/stream_settings_ui.js
@@ -699,7 +699,7 @@ function show_right_section() {
resize.resize_stream_subscribers_list();
}
-export function change_state(section, right_side_tab) {
+export function change_state(section, left_side_tab, right_side_tab) {
// if in #streams/new form.
if (section === "new") {
do_open_create_stream();
@@ -718,6 +718,20 @@ export function change_state(section, right_side_tab) {
const stream_id = Number.parseInt(section, 10);
show_right_section();
stream_edit_toggler.set_select_tab(right_side_tab);
+
+ if (left_side_tab === undefined) {
+ left_side_tab = "all-streams";
+ if (stream_data.is_subscribed(stream_id)) {
+ left_side_tab = "subscribed";
+ }
+ }
+
+ // Callback to .goto() will update browser_history unless a
+ // stream is being edited. We are always editing a stream here
+ // so its safe to call
+ if (left_side_tab !== toggler.value()) {
+ toggler.goto(left_side_tab);
+ }
switch_to_stream_row(stream_id);
return;
}
@@ -726,7 +740,7 @@ export function change_state(section, right_side_tab) {
stream_edit.empty_right_panel();
}
-export function launch(section, right_side_tab) {
+export function launch(section, left_side_tab, right_side_tab) {
setup_page(() => {
overlays.open_overlay({
name: "subscriptions",
@@ -736,7 +750,7 @@ export function launch(section, right_side_tab) {
$(".colorpicker").spectrum("destroy");
},
});
- change_state(section, right_side_tab);
+ change_state(section, left_side_tab, right_side_tab);
});
if (!stream_settings_components.get_active_data().id) {
if (section === "new") {