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.

util: Fix `is_topic_name_considered_empty` function.

Prakhar Pratyush0642c7a26425
diff --git a/web/src/util.ts b/web/src/util.ts
index 15a27b83ab9..5151657a8aa 100644
--- a/web/src/util.ts
+++ b/web/src/util.ts
@@ -559,8 +559,8 @@ export function is_topic_name_considered_empty(topic: string): boolean {
// NOTE: Use this check only when realm.realm_mandatory_topics is set to true.
topic = topic.trim();
// When the topic is mandatory in a realm via realm_mandatory_topics, the topic
- // can't be an empty string, "(no topic)", or realm_empty_topic_display_name.
- if (topic === "" || topic === "(no topic)" || topic === realm.realm_empty_topic_display_name) {
+ // can't be an empty string, "(no topic)", or the displayed topic name for empty string.
+ if (topic === "" || topic === "(no topic)" || topic === get_final_topic_display_name("")) {
return true;
}
return false;
diff --git a/web/tests/util.test.cjs b/web/tests/util.test.cjs
index 6732f8575ee..5df8fceb343 100644
--- a/web/tests/util.test.cjs
+++ b/web/tests/util.test.cjs
@@ -532,7 +532,7 @@ run_test("get_final_topic_display_name", ({override}) => {
run_test("is_topic_name_considered_empty", ({override}) => {
// Topic is not considered empty if it is distinct string
- // other than "(no topic)", or realm_empty_topic_display_name.
+ // other than "(no topic)", or the displayed topic name for empty string.
assert.ok(!util.is_topic_name_considered_empty("some topic"));
// Topic is considered empty if it is an empty string.
@@ -541,9 +541,10 @@ run_test("is_topic_name_considered_empty", ({override}) => {
// Topic is considered empty if it is equal to "(no topic)".
assert.ok(util.is_topic_name_considered_empty("(no topic)"));
- // Topic name is considered empty if it is equal to realm_empty_topic_display_name.
+ // Topic name is considered empty if it is equal to the displayed
+ // topic name for empty string.
override(realm, "realm_empty_topic_display_name", "general chat");
- assert.ok(util.is_topic_name_considered_empty("general chat"));
+ assert.ok(util.is_topic_name_considered_empty("translated: general chat"));
});
run_test("get_retry_backoff_seconds", () => {