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.

hash_util: Use correct type for `encode_operand`.

Aman Agrawala4b1b307b131
diff --git a/web/src/hash_util.ts b/web/src/hash_util.ts
index 7fb2f9432ec..e971262d73d 100644
--- a/web/src/hash_util.ts
+++ b/web/src/hash_util.ts
@@ -17,14 +17,13 @@ import {
narrow_operator_schema,
realm,
} from "./state_data.ts";
-import type {NarrowCanonicalTerm} from "./state_data.ts";
+import type {NarrowCanonicalOperator, NarrowCanonicalTerm} from "./state_data.ts";
import * as stream_data from "./stream_data.ts";
import * as sub_store from "./sub_store.ts";
import type {StreamSubscription} from "./sub_store.ts";
import * as user_groups from "./user_groups.ts";
import type {UserGroup} from "./user_groups.ts";
import {user_settings} from "./user_settings.ts";
-import * as util from "./util.ts";
export function get_reload_hash(): string {
let hash = window.location.hash;
@@ -34,21 +33,15 @@ export function get_reload_hash(): string {
return hash;
}
-export function encode_operand(operator: string, operand: string): string {
- if (
- operator === "group-pm-with" ||
- operator === "dm-including" ||
- operator === "dm" ||
- operator === "sender" ||
- operator === "pm-with"
- ) {
+export function encode_operand(operator: NarrowCanonicalOperator, operand: string): string {
+ if (operator === "dm-including" || operator === "dm" || operator === "sender") {
const slug = people.emails_to_slug(operand);
if (slug) {
return slug;
}
}
- if (util.canonicalize_channel_synonyms(operator) === "channel") {
+ if (operator === "channel") {
const stream_id = Number.parseInt(operand, 10);
return encode_stream_id(stream_id);
}
diff --git a/web/src/util.ts b/web/src/util.ts
index 65df33e640a..bc159f545f6 100644
--- a/web/src/util.ts
+++ b/web/src/util.ts
@@ -271,19 +271,6 @@ export function is_channels_synonym(text: string): boolean {
return text === "streams";
}
-export function canonicalize_channel_synonyms(text: string): string {
- if (is_channel_synonym(text.toLowerCase())) {
- // Function is removed in later commits.
- /* istanbul ignore next */
- return "channel";
- }
- if (is_channels_synonym(text.toLowerCase())) {
- /* istanbul ignore next */
- return "channels";
- }
- return text;
-}
-
export function prefix_match({value, search_term}: {value: string; search_term: string}): boolean {
return filter_by_word_prefix_match([value], search_term, (s) => s).length === 1;
}
diff --git a/web/tests/hashchange.test.cjs b/web/tests/hashchange.test.cjs
index 63fdb67651d..b236ed5d2c6 100644
--- a/web/tests/hashchange.test.cjs
+++ b/web/tests/hashchange.test.cjs
@@ -178,14 +178,6 @@ run_test("people_slugs", () => {
assert.equal(hash, "#narrow/dm/42-Alice-Smith");
narrow = hash_util.parse_narrow(hash.split("/"));
assert.deepEqual(narrow, [{operator: "dm", operand: "[email protected]", negated: false}]);
-
- // Even though we renamed "pm-with" to "dm", preexisting
- // links/URLs with "pm-with" operator are handled correctly.
- terms = [{operator: "pm-with", operand: "[email protected]"}];
- hash = hash_util.search_terms_to_hash(terms);
- assert.equal(hash, "#narrow/pm-with/42-Alice-Smith");
- narrow = hash_util.parse_narrow(hash.split("/"));
- assert.deepEqual(narrow, [{operator: "dm", operand: "[email protected]", negated: false}]);
});
function test_helper({override, override_rewire, change_tab}) {