streams-settings-overlay: Update hash for stream to channel rename.

Updates the base hash for the streams setting overlay to be
"channels" instead of "streams".

Because there are Welcome Bot and Notification Bot messages that
would have been sent with the "/#streams" hash, we will need to
support parsing those overlay hashes as an alias for "/#channels"
permanently.

Part of the stream to channels rename project.
This commit is contained in:
Lauryn Menard
2024-04-30 13:30:24 +02:00
committed by Tim Abbott
parent 21ba90c0ff
commit 8e953d9896
25 changed files with 89 additions and 72 deletions

View File

@@ -1,11 +1,11 @@
export function get_hash_category(hash?: string): string {
// given "#streams/subscribed", returns "streams"
// given "#channels/subscribed", returns "channels"
return hash ? hash.replace(/^#/, "").split(/\//)[0] : "";
}
export function get_hash_section(hash?: string): string {
// given "#settings/profile", returns "profile"
// given '#streams/5/social", returns "5"
// given '#channels/5/social", returns "5"
if (!hash) {
return "";
}
@@ -17,7 +17,7 @@ export function get_hash_section(hash?: string): string {
function get_nth_hash_section(hash: string, n: number): string {
// given "#settings/profile" and n=1, returns "profile"
// given '#streams/5/social" and n=2, returns "social"
// given '#channels/5/social" and n=2, returns "social"
const parts = hash.replace(/\/$/, "").split(/\//);
return parts.at(n) ?? "";
}
@@ -49,7 +49,13 @@ export function is_same_server_message_link(url: string): boolean {
export function is_overlay_hash(hash: string): boolean {
// Hash changes within this list are overlays and should not unnarrow (etc.)
const overlay_list = [
// In 2024, stream was renamed to channel in the Zulip API and UI.
// Because pre-change Welcome Bot and Notification Bot messages
// included links to "/#streams/all" and "/#streams/new", we'll
// need to support "streams" as an overlay hash as an alias for
// "channels" permanently.
"streams",
"channels",
"drafts",
"groups",
"settings",
@@ -72,7 +78,7 @@ export function is_overlay_hash(hash: string): boolean {
export function is_editing_stream(desired_stream_id: number): boolean {
const hash_components = window.location.hash.slice(1).split(/\//);
if (hash_components[0] !== "streams") {
if (hash_components[0] !== "channels") {
return false;
}
@@ -88,7 +94,7 @@ export function is_editing_stream(desired_stream_id: number): boolean {
}
export function is_create_new_stream_narrow(): boolean {
return window.location.hash === "#streams/new";
return window.location.hash === "#channels/new";
}
// This checks whether the user is in the stream settings menu
@@ -96,7 +102,7 @@ export function is_create_new_stream_narrow(): boolean {
export function is_subscribers_section_opened_for_stream(): boolean {
const hash_components = window.location.hash.slice(1).split(/\//);
if (hash_components[0] !== "streams") {
if (hash_components[0] !== "channels") {
return false;
}
if (!hash_components[3]) {