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.

refactor: Move `replace_emoji_with_text` from `ui` to `ui_util`.

Lalitb55ee161e2f8
diff --git a/web/src/notifications.js b/web/src/notifications.js
index 92593d25394..eabbfc910dc 100644
--- a/web/src/notifications.js
+++ b/web/src/notifications.js
@@ -23,7 +23,6 @@ import * as settings_config from "./settings_config";
import * as spoilers from "./spoilers";
import * as stream_data from "./stream_data";
import * as stream_ui_updates from "./stream_ui_updates";
-import * as ui from "./ui";
import * as ui_util from "./ui_util";
import * as unread from "./unread";
import * as unread_ops from "./unread_ops";
@@ -258,7 +257,7 @@ export function process_notification(notification) {
let notification_source;
// Convert the content to plain text, replacing emoji with their alt text
const $content = $("<div>").html(message.content);
- ui.replace_emoji_with_text($content);
+ ui_util.replace_emoji_with_text($content);
spoilers.hide_spoilers_in_notification($content);
if (
diff --git a/web/src/ui.js b/web/src/ui.js
index 89f9a43db79..d7dc88bed38 100644
--- a/web/src/ui.js
+++ b/web/src/ui.js
@@ -3,15 +3,6 @@ import SimpleBar from "simplebar";
// What, if anything, obscures the home tab?
-export function replace_emoji_with_text($element) {
- $element.find(".emoji").replaceWith(function () {
- if ($(this).is("img")) {
- return $(this).attr("alt");
- }
- return $(this).text();
- });
-}
-
export function get_content_element($element) {
const element = $element.expectOne()[0];
const sb = SimpleBar.instances.get(element);
diff --git a/web/src/ui_util.ts b/web/src/ui_util.ts
index a04aa362295..286317a4033 100644
--- a/web/src/ui_util.ts
+++ b/web/src/ui_util.ts
@@ -21,6 +21,15 @@ export function place_caret_at_end(el: HTMLElement): void {
}
}
+export function replace_emoji_with_text($element: JQuery): void {
+ $element.find(".emoji").replaceWith(function () {
+ if ($(this).is("img")) {
+ return $(this).attr("alt") ?? "";
+ }
+ return $(this).text();
+ });
+}
+
export function blur_active_element(): void {
// this blurs anything that may perhaps be actively focused on.
if (document.activeElement instanceof HTMLElement) {