hash-util: Rename stream_edit_url to channels_settings_edit_url.

Renames the hash_util.stream_edit_url function so that it's clearer
this is for the settings overlay hash and for the stream to channel
rename.
This commit is contained in:
Lauryn Menard
2024-04-30 14:46:11 +02:00
committed by Tim Abbott
parent 8e953d9896
commit ee84b277ec
7 changed files with 21 additions and 15 deletions

View File

@@ -475,7 +475,10 @@ export class BuddyList extends BuddyListConf {
stream_data.can_view_subscribers(current_sub) &&
has_inactive_users_matching_view
) {
const stream_edit_hash = hash_util.stream_edit_url(current_sub, "subscribers");
const stream_edit_hash = hash_util.channels_settings_edit_url(
current_sub,
"subscribers",
);
$("#buddy-list-users-matching-view-container").append(
$(
render_view_all_subscribers({

View File

@@ -144,12 +144,6 @@ export function by_conversation_and_time_url(message: Message): string {
return absolute_url + people.pm_perma_link(message) + suffix;
}
export function stream_edit_url(sub: StreamSubscription, right_side_tab: string): string {
return `#channels/${sub.stream_id}/${internal_url.encodeHashComponent(
sub.name,
)}/${right_side_tab}`;
}
export function group_edit_url(group: UserGroup, right_side_tab: string): string {
const hash = `#groups/${group.id}/${internal_url.encodeHashComponent(group.name)}/${right_side_tab}`;
return hash;
@@ -192,6 +186,15 @@ export function parse_narrow(hash: string): NarrowTerm[] | undefined {
return terms;
}
export function channels_settings_edit_url(
sub: StreamSubscription,
right_side_tab: string,
): string {
return `#channels/${sub.stream_id}/${internal_url.encodeHashComponent(
sub.name,
)}/${right_side_tab}`;
}
export function channels_settings_section_url(section = "subscribed"): string {
const valid_section_values = new Set(["new", "subscribed", "all"]);
if (!valid_section_values.has(section)) {
@@ -233,7 +236,7 @@ export function validate_channels_settings_hash(hash: string): string {
if (!valid_right_side_tab_values.has(right_side_tab)) {
right_side_tab = "general";
}
return stream_edit_url(sub, right_side_tab);
return channels_settings_edit_url(sub, right_side_tab);
}
return channels_settings_section_url(section);

View File

@@ -82,7 +82,7 @@ function get_message_view_header_context(filter: Filter | undefined): MessageVie
rendered_narrow_description: current_stream.rendered_description,
sub_count,
stream: current_stream,
stream_settings_link: hash_util.stream_edit_url(current_stream, "general"),
stream_settings_link: hash_util.channels_settings_edit_url(current_stream, "general"),
};
}
return icon_data;

View File

@@ -29,7 +29,7 @@ export function setup_toggler(): void {
const stream_id = Number.parseInt($stream_header.attr("data-stream-id") ?? "", 10);
const sub = sub_store.get(stream_id);
if (sub) {
const hash = hash_util.stream_edit_url(sub, select_tab);
const hash = hash_util.channels_settings_edit_url(sub, select_tab);
browser_history.update(hash);
}
},

View File

@@ -121,7 +121,7 @@ function build_stream_popover(opts) {
const sub = stream_popover_sub(e);
hide_stream_popover();
const stream_edit_hash = hash_util.stream_edit_url(sub, "general");
const stream_edit_hash = hash_util.channels_settings_edit_url(sub, "general");
browser_history.go_to_location(stream_edit_hash);
});

View File

@@ -196,7 +196,7 @@ function format_user_stream_list_item_html(stream, user) {
show_unsubscribe_button,
show_private_stream_unsub_tooltip,
show_last_user_in_private_stream_unsub_tooltip,
stream_edit_url: hash_util.stream_edit_url(stream, "general"),
stream_edit_url: hash_util.channels_settings_edit_url(stream, "general"),
});
}
@@ -927,7 +927,7 @@ export function initialize() {
(people.is_my_user_id(target_user_id) ||
peer_data.get_subscriber_count(stream_id) === 1)
) {
const new_hash = hash_util.stream_edit_url(sub, "general");
const new_hash = hash_util.channels_settings_edit_url(sub, "general");
hide_user_profile();
browser_history.go_to_location(new_hash);
return;

View File

@@ -196,13 +196,13 @@ run_test("test_parse_narrow", () => {
]);
});
run_test("test_stream_edit_url", () => {
run_test("test_channels_settings_edit_url", () => {
const sub = {
name: "research & development",
stream_id: 42,
};
assert.equal(
hash_util.stream_edit_url(sub, "general"),
hash_util.channels_settings_edit_url(sub, "general"),
"#channels/42/research.20.26.20development/general",
);
});