topics: Change topic links of left sidebar to use new permalinks.

This commit updates the topic links obtained from clicking
the topics in the left sidebar, recent view and inbox, and
those obtained from "Copy link to topic" to use the new
topic permalinks.

Fixes part of #21505.
This commit is contained in:
roanster007
2024-06-01 19:12:54 +05:30
committed by Tim Abbott
parent e67786154a
commit 41f30e1052
12 changed files with 79 additions and 10 deletions

View File

@@ -57,13 +57,22 @@ export function by_stream_url(
return `#narrow/channel/${encode_stream_id(stream_id, maybe_get_stream_name)}`;
}
// The message_id parameter is used to obtain topic permalinks,
// by using it in a `with` operator.
export function by_stream_topic_url(
stream_id: number,
topic: string,
maybe_get_stream_name: MaybeGetStreamName,
message_id?: number,
): string {
if (message_id === undefined) {
return `#narrow/channel/${encode_stream_id(
stream_id,
maybe_get_stream_name,
)}/topic/${encodeHashComponent(topic)}`;
}
return `#narrow/channel/${encode_stream_id(
stream_id,
maybe_get_stream_name,
)}/topic/${encodeHashComponent(topic)}`;
)}/topic/${encodeHashComponent(topic)}/with/${message_id}`;
}