Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
util: Remove format_array_as_list_with_highlighted_elements.
Anders Kaseorg9bf3696da234
diff --git a/web/src/util.ts b/web/src/util.tsindex 8a3f337673b..a1285eab989 100644--- a/web/src/util.ts+++ b/web/src/util.ts@@ -1,4 +1,3 @@-import Handlebars from "handlebars/runtime.js";import _ from "lodash";import * as z from "zod/mini";@@ -452,38 +451,6 @@ export function format_array_as_list_with_conjunction(return format_array_as_list(array, join_strategy, "conjunction");}-export function format_array_as_list_with_highlighted_elements(- array: string[],- style: Intl.ListFormatStyle,- type: Intl.ListFormatType,-): string {- // If Intl.ListFormat is not supported- if (Intl.ListFormat === undefined) {- return array- .map(- (item) =>- `<b class="highlighted-element">${Handlebars.Utils.escapeExpression(item)}</b>`,- )- .join(", ");- }-- // Use Intl.ListFormat to format the array as a Internationalized list.- const list_formatter = new Intl.ListFormat(user_settings.default_language, {style, type});-- const formatted_parts = list_formatter.formatToParts(array);- return formatted_parts- .map((part) => {- // There are two types of parts: elements (the actual- // items), and literals (commas, etc.). We need to- // HTML-escape the elements, but not the literals.- if (part.type === "element") {- return `<b class="highlighted-element">${Handlebars.Utils.escapeExpression(part.value)}</b>`;- }- return part.value;- })- .join("");-}-// Returns the remaining time in milliseconds from the start_time and duration.export function get_remaining_time(start_time: number, duration: number): number {return Math.max(0, start_time + duration - Date.now());diff --git a/web/tests/util.test.cjs b/web/tests/util.test.cjsindex 250f597508d..d97018589ba 100644--- a/web/tests/util.test.cjs+++ b/web/tests/util.test.cjs@@ -373,10 +373,6 @@ run_test("format_array_as_list", () => {util.format_array_as_list(array, "long", "conjunction"),"apple, banana, and orange",);- assert.equal(- util.format_array_as_list_with_highlighted_elements(array, "long", "conjunction"),- '<b class="highlighted-element">apple</b>, <b class="highlighted-element">banana</b>, and <b class="highlighted-element">orange</b>',- );// Conjunction formatassert.equal(@@ -395,10 +391,6 @@ run_test("format_array_as_list", () => {util.format_array_as_list(array, "long", "conjunction"),"apple, banana, orange",);- assert.equal(- util.format_array_as_list_with_highlighted_elements(array, "long", "conjunction"),- '<b class="highlighted-element">apple</b>, <b class="highlighted-element">banana</b>, <b class="highlighted-element">orange</b>',- );assert.equal(util.format_array_as_list_with_conjunction(array, "narrow"),