stream_settings: Show relevant streams in left panel.

We want to make the default stream listing more relevant. To do this,
we always show "All streams" tab when stream is opened from another
user's profile. From other places, we show "Subscribed" if the user
is subscribed to the stream they are trying to edit otherwise
"All streams" are shown.
This commit is contained in:
tnmkr 2024-02-24 22:25:39 +05:30 committed by Tim Abbott
parent 9275a8ded4
commit 25cca93bc9
2 changed files with 29 additions and 5 deletions

View File

@ -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;
}

View File

@ -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") {